Developer Documentation

Fully compatible with the OpenAI API format — just change base_url and you're ready to go.

Migrate in 3 Minutes

Already using the OpenAI SDK? Switch to itapi.ai with one line of code.

Before (OpenAI)

client = OpenAI(
    api_key="sk-...",
    # default base_url
)

After (itapi.ai)

client = OpenAI(
    api_key="it_...",
    base_url="https://www.itapi.ai/v1"
)
  1. Sign up and get your API key at itapi.ai
  2. Set base_url to https://www.itapi.ai/v1
  3. Replace your key — that's it. Every other line of your code stays the same.
Get Your API Key →

Authentication

API Key

All API requests require an API key passed in the Authorization header using the Bearer scheme. Keys are prefixed with it_.

Authorization: Bearer it_your_api_key_here

Create and manage your API keys from the dashboard.

⚠️ Security: Never expose your API key in client-side code or public repositories. Use environment variables (e.g. ITAPI_KEY) in production.

Quick Start

Base URL

All endpoints are served under this base path:

https://www.itapi.ai/v1

Code Examples

All examples use the standard OpenAI SDK. No custom libraries required — just point the client at itapi.ai.

Python (OpenAI SDK)
from openai import OpenAI

client = OpenAI(
    base_url="https://www.itapi.ai/v1",
    api_key="it_your_api_key_here"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Explain quantum computing in simple terms."}
    ]
)

print(response.choices[0].message.content)
Node.js (OpenAI SDK)
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://www.itapi.ai/v1',
  apiKey: 'it_your_api_key_here'
})

const response = await client.chat.completions.create({
  model: 'claude-3-5-sonnet-20241022',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'Explain quantum computing in simple terms.' }
  ]
})

console.log(response.choices[0].message.content)
cURL
curl https://www.itapi.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer it_your_api_key_here" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    "temperature": 0.7,
    "max_tokens": 512
  }'
Go (OpenAI SDK)
package main

import (
    "context"
    "fmt"
    "github.com/openai/openai-go"
    "github.com/openai/openai-go/option"
)

func main() {
    client := openai.NewClient(
        option.WithAPIKey("it_your_api_key_here"),
        option.WithBaseURL("https://www.itapi.ai/v1"),
    )

    completion, err := client.Chat.Completions.New(
        context.Background(),
        openai.ChatCompletionNewParams{
            Model: openai.F("gpt-4o"),
            Messages: openai.F([]openai.ChatCompletionMessageParamUnion{
                openai.SystemMessage("You are a helpful assistant."),
                openai.UserMessage("Explain quantum computing in simple terms."),
            }),
        },
    )
    if err != nil {
        panic(err)
    }

    fmt.Println(completion.Choices[0].Message.Content)
}

Streaming

Enable Server-Sent Events (SSE) streaming by setting stream: true. Streamed chunks follow the standard OpenAI delta format.

Python — Streaming
from openai import OpenAI

client = OpenAI(
    base_url="https://www.itapi.ai/v1",
    api_key="it_your_api_key_here"
)

stream = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Tell me a short story."}],
    stream=True
)

for chunk in stream:
    content = chunk.choices[0].delta.content
    if content:
        print(content, end="", flush=True)
print()  # final newline
Node.js — Streaming
import OpenAI from 'openai'

const client = new OpenAI({
  baseURL: 'https://www.itapi.ai/v1',
  apiKey: 'it_your_api_key_here'
})

const stream = await client.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Tell me a short story.' }],
  stream: true
})

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '')
}
console.log()
cURL — Streaming
curl https://www.itapi.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer it_your_api_key_here" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "user", "content": "Tell me a short story."}
    ],
    "stream": true
  }'

API Reference

POST/v1/chat/completions

Creates a model response for a given chat conversation. Follows the OpenAI Chat Completions specification.

ParameterTypeRequiredDescription
modelstringYesModel ID to use. Examples: gpt-4o, gpt-4o-mini, claude-3-5-sonnet-20241022, claude-3-opus-20240229, deepseek-chat, gemini-2.0-flash. See the Models page for the full list.
messagesarrayYesArray of message objects, each with role (system | user | assistant | function | tool) and content (string or array of content parts).
streambooleanNoWhen true, responses are streamed as Server-Sent Events (SSE). Defaults to false.
temperaturenumberNoSampling temperature between 0 and 2. Higher values produce more random outputs. Default varies by model.
max_tokensintegerNoMaximum number of tokens to generate in the completion. Useful for controlling cost and response length.
top_pnumberNoNucleus sampling parameter between 0 and 1. Only tokens with cumulative probability ≥ top_p are considered. Default is 1.
frequency_penaltynumberNoPenalizes repeated tokens. Values range from -2.0 to 2.0. Positive values reduce repetition.
presence_penaltynumberNoPenalizes tokens that have already appeared. Values range from -2.0 to 2.0. Positive values encourage new topics.
stopstring | arrayNoUp to 4 sequences where the API will stop generating further tokens.
nintegerNoNumber of completion choices to generate for each input message. Default is 1.
seedintegerNoIf specified, the system attempts to produce deterministic results. Useful for testing and reproducibility.
userstringNoUnique identifier for your end-user. Helps with monitoring and abuse detection.
toolsarrayNoList of tool/function definitions the model may call. Follows the OpenAI function-calling schema.
tool_choicestring | objectNoControls how the model calls tools. Can be 'none', 'auto', 'required', or a specific tool object.
response_formatobjectNoSpecifies the output format. Use { type: 'json_object' } for JSON mode (must include 'json' in your prompt).
logprobsbooleanNoWhether to return log probabilities of the output tokens. Default is false.
top_logprobsintegerNoNumber of most likely tokens to return at each position when logprobs is true. Integer between 0 and 20.

Request Body

{
  "model": "gpt-4o",
  "messages": [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ],
  "temperature": 0.7,
  "max_tokens": 1024,
  "top_p": 1,
  "stream": false
}

Response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1700000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 9,
    "total_tokens": 34
  }
}

Rate Limits

TierRequests / MinuteTokens / Minute
Free1020,000
Starter60100,000
Pro300500,000
EnterpriseCustomCustom

Rate-limit headers (x-ratelimit-*) are included in every response. Need higher limits? Contact us.

Error Codes

Errors follow the OpenAI error format with an error object containing message, type, and code fields.

HTTP StatusCodeDescription
400invalid_request_errorMalformed request body, missing required fields, or invalid parameter values.
401authentication_errorInvalid or missing API key. Check your Authorization header and ensure the key is active.
402insufficient_quotaYour account has run out of credits or hit your usage limit. Top up from the dashboard.
429rate_limit_exceededToo many requests. Wait before retrying — check the Retry-After header for the backoff time.
500api_errorUnexpected server error. Itapi.ai engineers are automatically notified. Retry with exponential backoff.
503server_overloadedThe service is temporarily overloaded. Retry after a short delay.