Power your apps with intelligent AI chat, code, and images
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| message | string | Yes | Your message to the AI |
| type | string | No | AI type: text, code, or img (default: text) |
| tone | string | No | Response tone: friendly, professional, humorous, casual (for text) |
| model | string | No | AI model (default: gpt-4o-mini) |
| temperature | number | No | Creativity 0-2 (default: 0.7) |
| maxTokens | number | No | Max response length (default: 500) |
| systemPrompt | string | No | Custom system instructions |
| conversation | array | No | Chat history for context |
const response = await fetch('https://aiapi.serverbay.org/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: 'Hello!',
type: 'text',
tone: 'friendly'
})
});
const data = await response.json();
console.log(data.response);
const response = await fetch('https://aiapi.serverbay.org/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: 'Write a function to add two numbers',
type: 'code'
})
});
const data = await response.json();
console.log(data.response);
const response = await fetch('https://aiapi.serverbay.org/api/chat', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
message: 'A cat sitting on a beach at sunset',
type: 'img'
})
});
const data = await response.json();
// data.image contains the base64 image
console.log(data.image);
import requests
response = requests.post(
'https://aiapi.serverbay.org/api/chat',
json={
'message': 'Hello!',
'type': 'text',
'tone': 'friendly'
}
)
data = response.json()
print(data['response'])
{
"message": "What was my last question?",
"type": "text",
"conversation": [
{ "role": "user", "content": "How does photosynthesis work?" },
{ "role": "assistant", "content": "Photosynthesis is the process..." }
]
}
{ "message": "Write a Python function to reverse a string", "type": "code" }
{ "message": "A futuristic city with flying cars", "type": "img" }