پرش به محتوای اصلی

مرجع API

این صفحه مستقیماً از قرارداد OpenAPI ساخته می‌شود؛ با هر تغییر در قرارداد به‌روزرسانی می‌شود.

مرجع API

POST/anthropic/v1/messagesAnthropic compatibility

Create an Anthropic-compatible message

احراز هویت: x-api-key: …

مشاهدهٔ راهنمای سازگاری با OpenAI و Anthropic

پارامترها

ناممحلالزامنوعتوضیح
anthropic-versionheaderالزامیstring—
anthropic-betaheaderاختیاریstringAccepted only when the selected model/protocol contract advertises that beta.
X-Correlation-IDheaderاختیاریstringOptional safe correlation value. Content-derived values are rejected.

پارامترهای بدنه

نامالزامنوعتوضیح
modelالزامیstring—
max_tokensالزامیinteger—
messagesالزامیarray<object>—
systemاختیاریoneOf[2]—
streamاختیاریboolean—
temperatureاختیاریnumber—
top_kاختیاریinteger—
top_pاختیاریnumber—
stop_sequencesاختیاریarray<string>—
toolsاختیاریarray<object>—
tool_choiceاختیاریoneOf[2]—
thinkingاختیاریoneOf[3]—
cache_controlاختیاریoneOf[2]—
containerاختیاریstring | null—
inference_geoاختیاریstring | null—
output_configاختیاریobject—
service_tierاختیاریenum(auto | standard_only)—
metadataاختیاریobject—

پاسخ‌ها

کدتوضیحنوع محتوا
200Native Anthropic-compatible JSON response or ordered SSE event stream.application/json, text/event-stream
400Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
401Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
402Native Anthropic-compatible billing error envelope.application/json
403Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
404Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
409Native Anthropic-compatible conflict error envelope.application/json
422Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
429Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
500Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
502Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
503Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json
504Native Anthropic-compatible gateway timeout error envelope.application/json
529Native Anthropic-compatible error envelope; overloaded errors use HTTP 529.application/json

رفتار استریم

قالب‌بندی
anthropic-native-sse
تلاش دوباره پیش از اولین بایت
exact-same-model-only
تلاش دوباره پس از اولین بایت
forbidden
ثبت محتوا
forbidden
POST/v1/chat/completionsOpenAI compatibility

Create an OpenAI-compatible chat completion

احراز هویت: Authorization: Bearer …

مشاهدهٔ راهنمای سازگاری با OpenAI و Anthropic

پارامترها

ناممحلالزامنوعتوضیح
X-Correlation-IDheaderاختیاریstringOptional safe correlation value. Content-derived values are rejected.

پارامترهای بدنه

نامالزامنوعتوضیح
modelالزامیstring—
messagesالزامیarray<oneOf[5]>—
streamاختیاریboolean—
stream_optionsاختیاریobject—
max_completion_tokensاختیاریinteger—
max_tokensاختیاریintegerLegacy spelling of `max_completion_tokens`, still sent by the OpenAI SDKs predating the rename and by `@ai-sdk/openai-compatible`. `max_completion_tokens` wins when both are present; exactly one output bound leaves the gateway.
temperatureاختیاریnumber | null—
top_pاختیاریnumber | null—
frequency_penaltyاختیاریnumber | null—
presence_penaltyاختیاریnumber | null—
nاختیاریinteger—
stopاختیاریoneOf[3]—
logprobsاختیاریboolean | null—
top_logprobsاختیاریinteger | null—
parallel_tool_callsاختیاریboolean—
reasoning_effortاختیاریenum(none | minimal | low | medium | high | xhigh | max | )—
verbosityاختیاریenum(low | medium | high | )—
thinkingاختیاریobjectThe thinking on/off switch DeepSeek V4 and Moonshot Kimi take on chat completions, sent by OpenCode (models.dev `toggle`), Cline and Cherry Studio. Only `type` is admitted; it reaches a provider only where a conformance capture verified it (captured 2026-10-20 on DeepSeek and Moonshot), and elsewhere it is `unsupported_capability` naming `thinking`.
response_formatاختیاریoneOf[3]—
service_tierاختیاریenum(auto | default | flex | scale | priority | )—
metadataاختیاریobject | null—
storeاختیاریenum(false | )Provider-side storage opt-out, accepted because OpenCode and the OpenAI SDKs send `store: false` on every request. The gateway never lets a provider store a completion, so only the opt-out is admitted (`true` is `unsupported_parameter`); it is not a routing parameter and is not forwarded upstream.
prompt_cache_keyاختیاریstring—
prompt_cache_optionsاختیاریobject—
safety_identifierاختیاریstring—
toolsاختیاریarray<object>—
tool_choiceاختیاریoneOf[2]—

پاسخ‌ها

کدتوضیحنوع محتوا
200Non-streaming JSON response or ordered SSE stream.application/json, text/event-stream
400Malformed request or unsupported parameter.application/json
401Missing, malformed, invalid, revoked, disabled, or expired credential.application/json
402Prepaid available balance is insufficient for a bounded reservation.application/json
403Authenticated key is not allowed to perform the operation.application/json
404Requested model or resource is not publicly available.application/json
409Idempotency, price-version, reservation, or state conflict.application/json
422Valid JSON violates model capability, context, or media constraints.application/json
429RPM, TPM, concurrency, or configured limit exceeded.application/json
500Unexpected safe internal failure.application/json
502Upstream response could not be safely normalized.application/json
503Exact model has no eligible healthy endpoint or maintenance is active.application/json
504Upstream provider exceeded the request timeout budget.application/json

رفتار استریم

قالب‌بندی
sse
تلاش دوباره پیش از اولین بایت
exact-same-model-only
تلاش دوباره پس از اولین بایت
forbidden
ثبت محتوا
forbidden
POST/v1/images/generationsOpenAI compatibility

Create an image for a model with verified image-generation capability

احراز هویت: Authorization: Bearer …

مشاهدهٔ راهنمای سازگاری با OpenAI و Anthropic

پارامترها

ناممحلالزامنوعتوضیح
X-Correlation-IDheaderاختیاریstringOptional safe correlation value. Content-derived values are rejected.

پارامترهای بدنه

نامالزامنوعتوضیح
modelالزامیstring—
promptالزامیstring—
nاختیاریinteger—
sizeاختیاریenum(auto | 256x256 | 512x512 | 1024x1024 | 1024x1536 | 1536x1024 | 1792x1024 | 1024x1792)—
qualityاختیاریenum(auto | low | medium | high | standard | hd)—
backgroundاختیاریenum(auto | transparent | opaque)—
output_formatاختیاریenum(png | jpeg | webp)—
response_formatاختیاریenum(url | b64_json)—
moderationاختیاریenum(low | auto)—
output_compressionاختیاریinteger—
partial_imagesاختیاریinteger—
streamاختیاریboolean—
styleاختیاریenum(vivid | natural)—
userاختیاریstring—

پاسخ‌ها

کدتوضیحنوع محتوا
200Generated image delivery references or bytes within the temporary delivery policy.application/json, text/event-stream
400Malformed request or unsupported parameter.application/json
401Missing, malformed, invalid, revoked, disabled, or expired credential.application/json
402Prepaid available balance is insufficient for a bounded reservation.application/json
403Authenticated key is not allowed to perform the operation.application/json
404Requested model or resource is not publicly available.application/json
409Idempotency, price-version, reservation, or state conflict.application/json
422Valid JSON violates model capability, context, or media constraints.application/json
429RPM, TPM, concurrency, or configured limit exceeded.application/json
500Unexpected safe internal failure.application/json
502Upstream response could not be safely normalized.application/json
503Exact model has no eligible healthy endpoint or maintenance is active.application/json
504Upstream provider exceeded the request timeout budget.application/json

رفتار استریم

قالب‌بندی
openai-image-native-sse
تلاش دوباره پیش از اولین بایت
exact-same-model-only
تلاش دوباره پس از اولین بایت
forbidden
ثبت محتوا
forbidden
GET/v1/modelsModels

List currently available and policy-visible models

احراز هویت: Authorization: Bearer …

مشاهدهٔ راهنمای سازگاری با OpenAI و Anthropic

پارامترها

ناممحلالزامنوعتوضیح
X-Correlation-IDheaderاختیاریstringOptional safe correlation value. Content-derived values are rejected.

پاسخ‌ها

کدتوضیحنوع محتوا
200Dynamic model catalog.application/json
401Missing, malformed, invalid, revoked, disabled, or expired credential.application/json
429RPM, TPM, concurrency, or configured limit exceeded.application/json
500Unexpected safe internal failure.application/json
503Exact model has no eligible healthy endpoint or maintenance is active.application/json
POST/v1/responsesOpenAI compatibility

Create an OpenAI-compatible response

احراز هویت: Authorization: Bearer …

مشاهدهٔ راهنمای سازگاری با OpenAI و Anthropic

پارامترها

ناممحلالزامنوعتوضیح
X-Correlation-IDheaderاختیاریstringOptional safe correlation value. Content-derived values are rejected.

پارامترهای بدنه

نامالزامنوعتوضیح
modelالزامیstring—
inputالزامیoneOf[2]—
instructionsاختیاریstring—
streamاختیاریboolean—
stream_optionsاختیاریobject—
max_output_tokensاختیاریinteger—
previous_response_idاختیاریstring | null—
conversationاختیاریoneOf[3]—
reasoningاختیاریobject—
textاختیاریobject—
metadataاختیاریobject | null—
includeاختیاریarray<enum(file_search_call.results | message.input_image.image_url | reasoning.encrypted_content | code_interpreter_call.outputs | web_search_call.action.sources)>—
safety_identifierاختیاریstring—
prompt_cache_keyاختیاریstring—
prompt_cache_optionsاختیاریobject—
parallel_tool_callsاختیاریboolean—
service_tierاختیاریenum(auto | default | flex | scale | priority | )—
temperatureاختیاریnumber | null—
top_pاختیاریnumber | null—
truncationاختیاریenum(auto | disabled | )—
toolsاختیاریarray<object>—
tool_choiceاختیاریoneOf[2]—

پاسخ‌ها

کدتوضیحنوع محتوا
200Non-streaming JSON response or ordered SSE stream.application/json, text/event-stream
400Malformed request or unsupported parameter.application/json
401Missing, malformed, invalid, revoked, disabled, or expired credential.application/json
402Prepaid available balance is insufficient for a bounded reservation.application/json
403Authenticated key is not allowed to perform the operation.application/json
404Requested model or resource is not publicly available.application/json
409Idempotency, price-version, reservation, or state conflict.application/json
422Valid JSON violates model capability, context, or media constraints.application/json
429RPM, TPM, concurrency, or configured limit exceeded.application/json
500Unexpected safe internal failure.application/json
502Upstream response could not be safely normalized.application/json
503Exact model has no eligible healthy endpoint or maintenance is active.application/json
504Upstream provider exceeded the request timeout budget.application/json

رفتار استریم

قالب‌بندی
sse
تلاش دوباره پیش از اولین بایت
exact-same-model-only
تلاش دوباره پس از اولین بایت
forbidden
ثبت محتوا
forbidden

نمونهٔ درخواست

curl "https://gateway.dothoosh.com/v1/chat/completions" \
  -H "Authorization: Bearer $DOTHOOSH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "YOUR_MODEL",
    "messages": [
      { "role": "system", "content": "پاسخ کوتاه بده." },
      { "role": "user", "content": "تهران کجاست؟" }
    ]
  }'

سرآیندها

احراز هویت
Authorization: Bearer …
Content-Type
application/json
X-Correlation-ID
اختیاری

محدودیت‌ها

api_key_rpm_exceeded
سقف درخواست در دقیقه تکمیل است
api_key_tpm_exceeded
سقف توکن در دقیقه تکمیل است
api_key_concurrency_exceeded
سقف درخواست هم‌زمان تکمیل است
api_key_or_account_spend_limit
سقف هزینهٔ کلید یا حساب رد شد