Documentation

API reference
POST/v1/chat/completions

Create Chat Completion

Creates a model response from conversation history with streaming, tools, and usage accounting.

ProtocolOpenAI Chat Completions
Reference categoryChat Completion

Compatible model examples

gpt-4ogpt-4.1gpt-5o3o4-mini
Keep the format. Choose your model.
cURL
curl -X POST https://api.routekey.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-your-key" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "Hello from Route Key"
    }
  ],
  "stream": false
}'
Example only · no request is sent
پارامترها
نامنوعالزامیتوضیح
modelstringبلهTarget model name from the Models page or model-list response.
messagesarray<object>بلهOpenAI-compatible chat messages for text endpoints.
temperaturenumberخیرSampling temperature.
top_pnumberخیرNucleus sampling value.
streambooleanخیرEnable server-sent streaming responses when supported.
max_tokensintegerخیرMaximum tokens for completion output.
toolsarray<object>خیرTool definitions or function schemas supported by the selected model.
response_formatobjectخیرOptional output format or response encoding.
پاسخ
نامنوعالزامیتوضیح
idstring-Response, task, or resource ID.
objectstring-Response object type.
createdinteger-Creation timestamp.
modelstring-Model used for the request.
choicesarray<object>-Candidate model outputs.
usageobject-Token usage statistics.
یادداشت‌ها
  • OpenAI Chat Completions
  • قالب سازگار، ساختار معمول SDK را حفظ می‌کند.
Your applicationRouteKeyOpenAI

مفاهیم

مفاهیم اصلی که پیش از نخستین درخواست لازم است بدانید.

کلید API: اعتبار Route Key که در هدر Authorization ارسال می‌شود.

Base URL: ورودی سازگار با SDK که درخواست را دریافت می‌کند.

نام مدل: شناسه دقیق از کاتالوگ مدل‌ها.

صورتحساب: گروه و نوع سهمیه قیمت واقعی درخواست را تعیین می‌کنند.

مدل‌ها

با مدل پشتیبانی‌شده و کم‌هزینه شروع کنید و فقط در صورت نیاز زمینه یا توان را افزایش دهید.

چت عمومی: با مدلی سریع و کم‌هزینه شروع کنید.

استدلال یا کدنویسی: در صورت نیاز به مدل استدلال قوی‌تر بروید.

Move up for reasoning

Check group pricing before production

خطاهای رایج

خطاهای رایج احراز هویت، سهمیه و قالب درخواست و روش رفع آن‌ها.

401

Authentication failed

Check that Authorization uses Bearer plus your Route Key API key.

403

No access or balance

Check key status, account balance, model access, and billing settings.

429

Quota or rate limit

Reduce concurrency, retry with backoff, or review account limits.

5xx

Upstream or routing failure

Retry later and inspect Usage Logs for route status and provider errors.