Skip to main content
Use CometAPI text model docs by matching your request format to the page that implements it. For OpenAI-compatible chat, start with Chat Completions or Responses; for provider-native formats, use the matching provider page.

Choose a text API

Chat Completions

Send OpenAI-compatible chat messages with a messages array.

Responses

Use reasoning, multimodal output, and built-in tools through the Responses API.

Anthropic Messages

Call Claude-compatible Messages workflows with provider-native fields.

Gemini content generation

Send Gemini native content generation requests.

Call a text model

Use any text-capable model ID from the Models page or the model directory. The examples below call the OpenAI-compatible Chat Completions endpoint.
These examples use the placeholder your-model-id. Replace it with an available text model ID from the Models page or model directory before you run the request.
import os
import requests

response = requests.post(
    "https://api.cometapi.com/v1/chat/completions",
    headers={
        "Authorization": "Bearer " + os.environ["COMETAPI_KEY"],
        "Content-Type": "application/json",
    },
    json={
        "model": "your-model-id",
        "messages": [
            {
                "role": "user",
                "content": "Write one sentence about CometAPI.",
            }
        ],
    },
    timeout=30,
)

response.raise_for_status()
result = response.json()
print(result["choices"][0]["message"]["content"])

Response example

A successful response can look like this. Field values vary by model and request:
{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "created": 1779960520,
  "model": "your-model-id",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "CometAPI lets developers route model requests through one API surface."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 14,
    "total_tokens": 26
  }
}

Example model records

This example model catalog response shows the /api/models envelope and one text model record shape. It is not a complete model list.
cURL
curl https://api.cometapi.com/api/models
{
  "success": true,
  "page": 1,
  "page_size": 20,
  "total": 302,
  "data": [
    {
      "created": 1773798949,
      "id": "your-text-model-id",
      "code": "your-text-model-id",
      "provider": "ExampleProvider",
      "provider_code": "example",
      "name": "Example text model",
      "model_type": "text",
      "features": [
        "text-to-text"
      ],
      "endpoints": "{\n  \"openai-chat\": {\n    \"path\": \"/v1/chat/completions\",\n    \"method\": \"POST\"\n  }\n}",
      "pricing": {
        "currency": "USD / M Tokens",
        "input": 0.5,
        "output": 1.5,
        "per_request": null,
        "per_second": null
      }
    }
  ]
}

Common errors

Send Authorization: Bearer $COMETAPI_KEY.
Use https://api.cometapi.com/v1 for OpenAI-compatible requests.
Choose a text-capable model from the Models page.
Remove optional fields, then add the fields back one at a time.

Error codes and retry strategy

Do not retry until the request body is fixed.
Do not retry until the API key is present and valid.
Check the base URL, path, and model ID before retrying.
Retry with exponential backoff and reduce concurrency.
Retry with backoff for transient provider or service errors.
For implementation patterns, see Error codes and retry strategy and Rate limits and concurrency.

Pricing and model directory

Models page

Read how CometAPI exposes model IDs in the docs.

Model directory

Browse model availability and capabilities.

Pricing

Check pricing before you call a model.
Last modified on May 28, 2026