Skip to content

OpenAI SDK Setup

QuotaAPI exposes OpenAI-compatible endpoints for the official Python and JavaScript SDKs and other clients that follow the same protocol.

See the OpenAI SDK integration overview for use cases and core capabilities.

Prerequisites

  1. Create a Key on the API Keys page.
  2. Bind the Key to a group that exposes the target model.
  3. Install a current stable OpenAI SDK.

Python

python
from openai import OpenAI

client = OpenAI(
    base_url="https://quotarouter.ai/v1",
    api_key="YOUR_QUOTAAPI_KEY",
)

response = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Reply with one short sentence."}],
)

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

JavaScript

js
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://quotarouter.ai/v1',
  apiKey: 'YOUR_QUOTAAPI_KEY',
})

const response = await client.chat.completions.create({
  model: 'gpt-5.5',
  messages: [{ role: 'user', content: 'Reply with one short sentence.' }],
})

console.log(response.choices[0].message.content)

Choose Chat Completions or Responses

  • Existing OpenAI-compatible applications commonly use /v1/chat/completions.
  • Codex and newer workflows can use /v1/responses.
  • DeepSeek groups support Chat Completions but not Responses.
  • Composite-group behavior follows the platform selected by model mapping.

Responses example:

python
response = client.responses.create(
    model="gpt-5.5",
    input="Summarize the value of an API gateway in one sentence.",
)

print(response.output_text)

Verify models and usage

List models first, then inspect console usage records for status, tokens, and charge:

bash
curl https://quotarouter.ai/v1/models \
  -H "Authorization: Bearer YOUR_QUOTAAPI_KEY"

See the OpenAI-compatible API reference for endpoint and parameter details.

Common errors

  • 401: the Key is invalid, disabled, or not sent as a Bearer token.
  • 404: the Base URL path is duplicated or the group does not support the endpoint.
  • 429: a Key quota, account concurrency limit, or platform rate limit was reached.
  • Browser security error: do not expose a long-lived API Key in browser code; call from your own server.

QuotaAPI is an AI API relay service for developers and teams.