Skip to content

API reference

Responses

The primary API for text, tools, streaming, and durable background work. Start with a simple request, then add capabilities as needed.

How it fits together

  1. 01Create a response
  2. 02Retrieve one owned response
  3. 03List the input items one owned response was asked

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

Create a response

POST/v1/responses
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.
backgroundBodybooleanOptionalSupportedAdmit the request durably and answer before the provider does.
chat_idBodystringOptionalMahvash extensionContinue a stored, owner-scoped conversation.
containerBodystring | objectOptionalConditionalProvider container configuration; needs explicit route support.
id_chatBodystringOptionalDeprecatedLegacy alias of chat_id. Prefer chat_id in new clients.
includeBodyarray<value>OptionalConditionalRequest additional response data from a capable route: web-search sources and results, file-search results, or output-text logprobs.
inputBodystring | array<value>RequiredSupportedText or typed input items.
instructionsBodystringOptionalSupportedSystem or developer instruction text.
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_output_tokensBodyintegerOptionalSupportedOutput-token ceiling.
max_tool_callsBodyintegerOptionalConditionalBounded by the service hosted-tool call cap.
metadataBodyobjectOptionalSupportedBounded metadata object echoed in the response.
modeBodystringOptionalMahvash extensionAutomatic model-selection mode when no explicit model is given.
modelBodystringOptionalSupportedPublic logical model ID. Defaults to automatic selection.
parallel_tool_callsBodybooleanOptionalConditionalAllow parallel tool calls where the route supports it.
previous_response_idBodystringOptionalSupportedContinue a completed response on its pinned route.
projectBodystringOptionalMahvash extensionProject slug or ID for this request; conflicts are rejected.
promptBodyobject | stringOptionalConditionalProvider prompt-template reference.
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.
reasoningBodyobjectOptionalConditionalReasoning configuration; the route must support the request.
safety_identifierBodystringOptionalSupportedStable provider safety identifier.
service_tierBodystringOptionalConditionalProvider service tier; needs route support.
storeBodybooleanOptionalConditionalProvider storage preference.
streamBodybooleanOptionalSupportedReturn typed Server-Sent Events.
temperatureBodynumberOptionalSupportedSampling temperature, 0 to 2.
textBodyobjectOptionalConditionalText and structured-output configuration. A json_schema format is bounded and validated before any provider call, and the returned document is checked against it.
text_formatBodyobjectOptionalMahvash extensionExplicit structured-output format alias.
tool_choiceBodystring | objectOptionalSupportedTool selection policy forwarded to a compatible route.
toolsBodyarray<value>OptionalConditionalFunction tools and the registered provider-hosted tools.
top_pBodynumberOptionalSupportedNucleus sampling, 0 to 1.
truncationBodystringOptionalConditionalProvider truncation mode.
userBodystringOptionalSupportedProvider abuse-monitoring user identifier.

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

Request

curl -X POST 'https://api.mahvashai.ir/v1/responses' \
  -H "Authorization: Bearer $MAHVASH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: <unique-request-id>" \
  -d '{
  "model": "auto",
  "input": "Summarize the value of a small, reliable API in one sentence."
}'

Response

{
  "id": "resp_example",
  "object": "response",
  "created_at": 1750000000,
  "status": "completed",
  "model": "<model-id>",
  "output": [
    {
      "id": "msg_example",
      "type": "message",
      "role": "assistant",
      "status": "completed",
      "content": [
        {
          "type": "output_text",
          "text": "Hello!",
          "annotations": []
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 11,
    "output_tokens": 4,
    "total_tokens": 15
  }
}

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

Status codes

HTTPDetails
200Create a response.
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.

Retrieve one owned response

GET/v1/responses/{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
pkPathstringRequiredSupportedResponse ID beginning with resp_.
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/responses/<pk>' \
  -H "Authorization: Bearer $MAHVASH_API_KEY"

Response

{
  "id": "<id>",
  "object": "<value>",
  "created_at": 0,
  "status": "queued",
  "background": false,
  "error": "<value>",
  "incomplete_details": "<value>",
  "instructions": "<value>",
  "max_output_tokens": "<value>",
  "model": "<value>",
  "output": [
    {
      "type": "<value>"
    }
  ],
  "parallel_tool_calls": false,
  "previous_response_id": "<id>",
  "reasoning": "<value>"
}

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

Status codes

HTTPDetails
200Retrieve one owned response.
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 the input items one owned response was asked

GET/v1/responses/{pk}/input_items
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
pkPathstringRequiredSupportedResponse ID beginning with resp_.
limitQueryintegerOptionalSupportedPage size, 1 to 100. Defaults to 20.
orderQuerystringOptionalSupportedasc (default) or desc, by item order.
afterQuerystringOptionalSupportedReturn items after this item ID.
beforeQuerystringOptionalSupportedReturn items before this item ID.
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/responses/<pk>/input_items' \
  -H "Authorization: Bearer $MAHVASH_API_KEY"

Response

{
  "object": "<value>",
  "data": [
    {
      "id": "<id>",
      "type": "<value>"
    }
  ],
  "first_id": "<id>",
  "last_id": "<id>",
  "has_more": false
}

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

Status codes

HTTPDetails
200List the input items one owned response was asked.
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 owned response

POST/v1/responses/{pk}/cancel
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
pkPathstringRequiredSupportedResponse ID to cancel.
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 POST 'https://api.mahvashai.ir/v1/responses/<pk>/cancel' \
  -H "Authorization: Bearer $MAHVASH_API_KEY"

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
200Request cancellation of an owned response.
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.

Delete an owned response

DELETE/v1/responses/{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
pkPathstringRequiredSupportedResponse ID to delete.
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/responses/<pk>' \
  -H "Authorization: Bearer $MAHVASH_API_KEY"

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
200Delete an owned response.
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.