Developer Documentation

Everything you need to integrate APIProxy.ai into your applications.

Quick Start

Get started with APIProxy.ai in under 5 minutes. Our API is OpenAI-compatible, so you can use existing SDKs.

Install the OpenAI SDK
pip install openai
Python
import openai

# Configure APIProxy.ai endpoint
openai.api_base = "https://api.apiproxy.ai/v1"
openai.api_key = "your-api-key-here"

# Make your first request
response = openai.ChatCompletion.create(
    model="megalodon-apex",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Hello!"}
    ]
)

print(response.choices[0].message.content)

Authentication

All API requests require authentication using an API key. Include your key in the Authorization header:

Authorization: Bearer YOUR_API_KEY
Keep your API keys secure

Never share your API keys publicly or commit them to version control.

Making Requests

The base URL for all API requests is:

https://api.apiproxy.ai/v1

Example using cURL:

curl https://api.apiproxy.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "megalodon-apex",
    "messages": [
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }'

Chat Completions API

The Chat Completions endpoint allows you to generate conversational responses.

Endpoint
POST /v1/chat/completions

Request Parameters

Parameter Type Description
model string Model ID (e.g., "megalodon-apex", "mosasaurus-ultra", "kronosaurus-fast")
messages array List of message objects with role and content
temperature number Sampling temperature (0-2). Optional, default: 1
max_tokens integer Maximum tokens to generate. Optional
stream boolean Enable streaming responses. Optional, default: false

Example Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1730707200,
  "model": "megalodon-apex",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 9,
    "total_tokens": 19
  }
}

Node.js Example

npm install openai
JavaScript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.apiproxy.ai/v1',
  apiKey: process.env.APIPROXY_API_KEY,
});

async function main() {
  const completion = await client.chat.completions.create({
    model: 'megalodon-apex',
    messages: [
      { role: 'system', content: 'You are a helpful assistant.' },
      { role: 'user', content: 'Hello!' }
    ],
  });

  console.log(completion.choices[0].message.content);
}

main();

Streaming Responses

Enable streaming to receive partial results as they're generated:

import openai

openai.api_base = "https://api.apiproxy.ai/v1"
openai.api_key = "your-api-key"

response = openai.ChatCompletion.create(
    model="mosasaurus-ultra",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True
)

for chunk in response:
    if chunk.choices[0].delta.get("content"):
        print(chunk.choices[0].delta.content, end="")

Error Handling

The API uses standard HTTP status codes:

Status Code Meaning
200 Success
401 Invalid API key
429 Rate limit exceeded
500 Server error
503 Service temporarily unavailable

Rate Limits

Rate limits vary by plan and model. Check response headers for limit information:

X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 9999
X-RateLimit-Reset: 1730707200

Need Help?

Our developer support team is here to help:

Documentation: docs.apiproxy.ai