Find a model
search_models searches the model catalog that your API key can access. The call is not billed.
The result contains
data, total, and nextOffset. To read the next page, pass the nextOffset value as offset. When nextOffset is null, the result contains the last page.
get_model_schema returns one model. Set model to a model ID from the search result. The call is not billed. The schemaStatus field shows how you can call the model:
Generate text
generate_text sends one prompt to gpt-6-astra and returns the generated text.
The tool accepts only the parameters in this table. For the complete Responses API, see Create a model response.
The result contains these fields:
status:completedorincompletetext: the generated textrefusal: the refusal message when the model declines the requestusage: the token counts ininputTokens,outputTokens,totalTokens, andreasoningTokens.outputTokensincludesreasoningTokens.incompleteReason:max_output_tokenswhen the output reached the token limit, orcontent_filterwhen a content filter stopped the output
incomplete.
If incompleteReason is max_output_tokens, send the request again with a higher max_output_tokens value. The second request is billed separately. If incompleteReason is content_filter, change the prompt.
Use a receipt for a long generation
A directgenerate_text call returns the text only in the response to that call. If the call runs for more than about 30 seconds, or the connection closes, the client receives no result. The request can still be billed, and the text cannot be read again.
With a receipt, the generation can run for up to 120 seconds, and you can read the result again until the receipt expires. Use a receipt when you set max_output_tokens above the default value.
1
Reserve a receipt
Call
prepare_text_generation. The result contains recoveryId. This call is not billed.2
Start the generation
Call
generate_text with your prompt, and set recovery_id to the recoveryId value. The call returns immediately with the state running.3
Read the result
While
state is running, call get_text_result with the same recovery_id. When state is completed, the generated text is in result.text. A read is not billed.generate_text call with the same receipt and the same parameters sends no new request and returns the state of the first request. A call with different parameters returns the receipt_rejected error. To send another request, reserve a new receipt.
A receipt is valid for 10 minutes after you reserve it. When you start the generation, the 10 minutes start again, and expiresAt shows the exact time.
Each API key can hold eight receipts at the same time. A receipt occupies its slot until it expires, including after its generation is completed. If prepare_text_generation returns the receipt_capacity_exceeded error, wait until a receipt expires, then reserve a receipt again. If generate_text returns this error for a receipt, wait until a running generation ends, then call the tool again.
Generate an image
generate_image submits one image task for gpt-image-2 and returns a task ID. A task is billed when the image is generated.
Each task creates one image. For other image options, see Create an image.
1
Submit the task
Call
generate_image. The result contains taskId and a status of pending, success, or failure.2
Read the task
While
status is pending, call get_task with task_id set to the taskId value. A task read is not billed. Do not call generate_image again, because each call submits a new task.3
Save the image
When
status is success, save the image with the command in the next section. The get_task result also contains the image as base64 text, in the b64_json field of the first item in data.status is failure, the task did not produce an image. The failReason field contains a general message. To read the cause, retrieve the task from the CometAPI API and read data.fail_reason. See Retrieve an image generation task. If the cause is a request error, correct the parameters and submit another task. For any other cause, contact CometAPI support with the task ID.
Save the image as a file
The base64 text of an image is large and can exceed the tool output limit of the client. To save the image without passing the base64 text through the conversation, retrieve the task from the CometAPI API with the same task ID and API key. In the API response, the task state is indata.status, and the image is in the b64_json field of the first item in data.data. The following command saves a JPEG image. Replace <task_id> with the task ID:
curl and jq. If the task is not yet success, or the API key is not valid, the command ends with a nonzero exit status, and the file is empty. For a PNG image, change the file name to image.png.
If the image does not fit in a tool result, get_task returns the image_output_too_large error. The task is still available from the CometAPI API.
Errors
When a tool reports an error, the result contains anerror object with these fields:
If the arguments do not match the parameters of a tool, the call returns a validation message instead of an
error object. The request is not sent, and it is not billed.
The submission field shows whether a request can be billed:
Successful results also contain
submission: completed in a text result, accepted from generate_image, and observed from get_task.
For the checks to make before you send a billed request again, see the Billing section of CometAPI MCP.