Skip to content

API reference

Conversations and Chat Completions

Use the familiar Chat Completions format when your client already speaks it. Conversation operations let you inspect saved messages and runs.

How it fits together

  1. 01Create a chat completion
  2. 02List owned conversations
  3. 03Retrieve conversation metadata

Select an action to see its complete inputs, request, response, and status codes.

Create a chat completion

POST/v1/chat/completions
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typeapplication/json

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
Idempotency-KeyHeaderstringOptionalSupportedReplay key for an admitted run; a repeat returns the first result.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
asset_idsBodyarray<value>OptionalMahvash extensionReusable owned files to attach to the latest user message.
audioBodyobjectOptionalConditionalAudio output configuration; requires an audio-output route.
chat_idBodystringOptionalMahvash extensionContinue a stored, owner-scoped conversation.
frequency_penaltyBodynumberOptionalSupportedFrequency penalty, -2 to 2.
function_callBodystring | objectOptionalDeprecatedLegacy function selection. Prefer tool_choice.
functionsBodyarray<value>OptionalDeprecatedLegacy function definitions. Prefer tools.
id_chatBodystringOptionalDeprecatedLegacy alias of chat_id. Prefer chat_id in new clients.
logit_biasBodyobjectOptionalConditionalUp to 300 token-ID biases between -100 and 100.
logprobsBodybooleanOptionalConditionalRequest token log probabilities; needs route support. Reported under choices[].logprobs, and per chunk while streaming.
managed_toolsBodyobjectOptionalMahvash extensionMahvash-executed tools. Absent: the project's capability tools are offered automatically; enabled=false turns them off; tools narrows the set; max_rounds caps the tool rounds.
max_completion_tokensBodyintegerOptionalSupportedCompletion-token ceiling, 1 to 1,000,000.
max_output_tokensBodyintegerOptionalMahvash extensionAccepted alias of max_completion_tokens.
max_tokensBodyintegerOptionalDeprecatedLegacy output-token ceiling. Prefer max_completion_tokens.
messagesBodyarray<value>RequiredSupportedConversation messages; 1 to 1,000 items.
metadataBodyobjectOptionalSupportedBounded provider/application metadata object.
modalitiesBodyarray<value>OptionalConditionalRequested output modalities; each needs an output capability.
modeBodystringOptionalMahvash extensionAutomatic model-selection mode when no explicit model is given.
modelBodystringOptionalSupportedPublic logical model ID. Defaults to automatic selection.
nBodyintegerOptionalConditionalNumber of choices. Values above 1 need explicit route support.
parallel_tool_callsBodybooleanOptionalConditionalAllow parallel tool calls where the route supports it.
predictionBodyobjectOptionalConditionalPredicted-output configuration forwarded to capable routes.
presence_penaltyBodynumberOptionalSupportedPresence penalty, -2 to 2.
projectBodystringOptionalMahvash extensionProject slug or ID for this request; conflicts are rejected.
prompt_cache_keyBodystringOptionalConditionalPrompt-cache partition name; namespaced per organization before it reaches the provider. Needs route support.
prompt_cache_retentionBodystringOptionalConditionalPrompt-cache retention preference; needs route support.
prompt_idBodystringOptionalMahvash extensionProject-owned prompt resource to append to the run instructions.
reasoning_effortBodystringOptionalConditionalMust be supported by the logical model and the route.
response_formatBodyobjectOptionalConditionaljson_object or json_schema; the route must declare the capability. A json_schema declaration is bounded and, under strict, validated before any provider call, and the returned document is checked against it.
safety_identifierBodystringOptionalSupportedStable safety identifier forwarded to a compatible route.
seedBodyintegerOptionalConditionalProvider determinism hint; needs route support.
service_tierBodystringOptionalConditionalProvider service-tier request; needs route support.
stopBodystring | array<value>OptionalSupportedUp to 4 stop sequences of at most 1,024 characters each.
streamBodybooleanOptionalSupportedReturn Server-Sent Events instead of one JSON object.
stream_optionsBodyobjectOptionalConditionalOnly include_usage is accepted.
temperatureBodynumberOptionalSupportedSampling temperature, 0 to 2.
thinkingBodyobjectOptionalMahvash extensionProvider reasoning configuration for routes that use it.
tool_choiceBodystring | objectOptionalSupportedauto, none, required, or a provider-compatible object.
toolsBodyarray<value>OptionalConditionalFunction tools only; hosted tools belong to Responses.
top_logprobsBodyintegerOptionalConditionalMost likely tokens per position, 0 to 20; needs route support.
top_pBodynumberOptionalSupportedNucleus sampling, 0 to 1.
userBodystringOptionalSupportedProvider abuse-monitoring user identifier.
verbosityBodystringOptionalConditionalProvider response verbosity option.
web_search_optionsBodyobjectOptionalConditionalRequires a route supporting web search and this parameter.

A compatible model and provider route are required for conditional fields.

Request

curl -X POST 'https://api.mahvashai.ir/v1/chat/completions' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <unique-request-id>" \
  -d '{
  "model": "auto",
  "messages": [
    {
      "role": "user",
      "content": "Say hello in one sentence."
    }
  ]
}'

Response

{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "created": 1750000000,
  "model": "<model-id>",
  "choices": [
    {
      "index": 0,
      "finish_reason": "stop",
      "message": {
        "role": "assistant",
        "content": "Hello!"
      }
    }
  ],
  "usage": {
    "prompt_tokens": 11,
    "completion_tokens": 4,
    "total_tokens": 15
  }
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200Create a chat completion.
400The request is not valid.
401Authentication credentials are missing or invalid.
402The account cannot authorize the request cost.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
502The selected provider returned an invalid or failed response.
503A dependency is temporarily unavailable.

List owned conversations

GET/v1/chat/completions
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
searchQuerystringOptionalMahvash extensionFilter conversations by title or message content.
statusQuerystringOptionalMahvash extensionFilter by conversation status.
modeQuerystringOptionalMahvash extensionFilter by conversation mode.
is_pinnedQuerybooleanOptionalMahvash extensionFilter pinned conversations.
orderingQuerystringOptionalMahvash extensionupdated_at or title, optionally prefixed with '-'.
cursorQuerystringOptionalMahvash extensionOpaque cursor from a previous page.
limitQueryintegerOptionalMahvash extensionRequested page size, capped by server policy.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.

Request

curl -X GET 'https://api.mahvashai.ir/v1/chat/completions' \
  -H "Authorization: Bearer $MAHVASH_API_KEY"

Response

{
  "object": "list",
  "data": [
    {
      "id": "<id>",
      "object": "chat.completion",
      "created": 1750000000,
      "model": null,
      "metadata": {
        "chat_id": "<id>",
        "title": "<value>",
        "is_pinned": false,
        "status": "ACTIVE",
        "mode": "<value>"
      }
    }
  ],
  "first_id": "<id>",
  "last_id": "<id>",
  "has_more": false,
  "next": null,
  "previous": null
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200List owned conversations.
400The request is not valid.
401Authentication credentials are missing or invalid.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
429A quota or rate limit was exceeded.
500An internal error occurred.

Retrieve conversation metadata

GET/v1/chat/completions/{pk}
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
pkPathstringRequiredMahvash extensionConversation ID, with or without the chatcmpl- prefix.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.

Request

curl -X GET 'https://api.mahvashai.ir/v1/chat/completions/<pk>' \
  -H "Authorization: Bearer $MAHVASH_API_KEY"

Response

{
  "id": "<id>",
  "object": "chat.completion",
  "created": 1750000000,
  "model": null,
  "metadata": {
    "chat_id": "<id>",
    "title": "<value>",
    "is_pinned": false,
    "status": "ACTIVE",
    "mode": "<value>"
  }
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200Retrieve conversation metadata.
401Authentication credentials are missing or invalid.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
429A quota or rate limit was exceeded.
500An internal error occurred.

List messages and attached files in a conversation

GET/v1/chat/completions/{pk}/messages
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
pkPathstringRequiredMahvash extensionConversation ID.
searchQuerystringOptionalMahvash extensionFilter messages by content substring.
cursorQuerystringOptionalMahvash extensionOpaque cursor from a previous page.
limitQueryintegerOptionalMahvash extensionRequested page size, capped by server policy.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.

Request

curl -X GET 'https://api.mahvashai.ir/v1/chat/completions/<pk>/messages' \
  -H "Authorization: Bearer $MAHVASH_API_KEY"

Response

{
  "object": "list",
  "data": [
    {
      "id": "<id>",
      "object": "chat.completion.message",
      "role": "user",
      "content": "<value>",
      "content_parts": [],
      "tool_calls": [],
      "attachments": [],
      "created": 1750000000,
      "metadata": {
        "status": "COMPLETED"
      }
    }
  ],
  "first_id": "<id>",
  "last_id": "<id>",
  "has_more": false,
  "next": null,
  "previous": null
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200List messages and attached files in a conversation.
400The request is not valid.
401Authentication credentials are missing or invalid.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
429A quota or rate limit was exceeded.
500An internal error occurred.

Request cancellation of an in-flight run

POST/v1/chat/completions/cancel
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response
Content typeapplication/json

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.
run_idBodystringRequiredMahvash extensionRun identifier returned by a queued or streaming request.

Request

curl -X POST 'https://api.mahvashai.ir/v1/chat/completions/cancel' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "run_id": "3f5a8c4e-6b8d-4a4f-9d2c-1f0a2b3c4d5e"
}'

Response

A representative JSON response is not available for this endpoint. Handle the documented HTTP status and inspect the returned body according to your client workflow.

Status codes

HTTPDetails
202Request cancellation of an in-flight run.
400The request is not valid.
401Authentication credentials are missing or invalid.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.
503A dependency is temporarily unavailable.

Redact and delete a conversation

DELETE/v1/chat/completions/{pk}
Production base URLhttps://api.mahvashai.ir
AuthenticationProject API key or user JWT
ResponseDirect OpenAI-style response

Parameters

The table shows the accepted inputs for this endpoint. Examples use placeholders and illustrate a safe integration pattern.

NameLocationTypeRequiredSupportDetails
pkPathstringRequiredMahvash extensionConversation ID to redact.
X-Request-IDHeaderstringOptionalMahvash extensionClient-supplied correlation ID. Echoed on every response; replaced when absent or malformed.
X-Mahvash-ProjectHeaderstringOptionalMahvash extensionProject slug or ID within the caller's organization. Narrows the request principal; it can never widen it.

Request

curl -X DELETE 'https://api.mahvashai.ir/v1/chat/completions/<pk>' \
  -H "Authorization: Bearer $MAHVASH_API_KEY"

Response

{
  "message": "<value>"
}

Illustrative response shape; actual fields depend on the operation and model.

Status codes

HTTPDetails
200Redact and delete a conversation.
401Authentication credentials are missing or invalid.
403The principal is not allowed to perform this request.
404No such resource is visible to this principal.
409The requested transition conflicts with durable resource state.
429A quota or rate limit was exceeded.
500An internal error occurred.