๐Ÿค– AI API

Power your apps with intelligent AI chat, code, and images

Base URL: https://aiapi.serverbay.org
API Online

๐Ÿ“ก API Endpoint

POST https://aiapi.serverbay.org/api/chat

Headers

Content-Type: application/json

Parameters

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

๐Ÿงช Try It Now

Response:

          Generated image
        

๐Ÿ’ป Code Examples

Text Chat

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);

Code Generation

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);

Image Generation

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);

Python

import requests

response = requests.post(
  'https://aiapi.serverbay.org/api/chat',
  json={
    'message': 'Hello!',
    'type': 'text',
    'tone': 'friendly'
  }
)

data = response.json()
print(data['response'])

๐Ÿ“‹ Example Requests

Text chat with conversation:

{
  "message": "What was my last question?",
  "type": "text",
  "conversation": [
    { "role": "user", "content": "How does photosynthesis work?" },
    { "role": "assistant", "content": "Photosynthesis is the process..." }
  ]
}

Code generation:

{ "message": "Write a Python function to reverse a string", "type": "code" }

Image generation:

{ "message": "A futuristic city with flying cars", "type": "img" }