Features
- Connect with one URL and your CometAPI API key, with nothing to install
- Search the model catalog that your API key can access, and inspect a model, at no charge
- Generate text with
gpt-6-astraand create images withgpt-image-2at the same price as CometAPI API requests - Recover a result after a disconnect: read a text receipt or an image task again at no charge
- Control charges: the server sends each generation request one time and does not retry it
Prerequisites
- A CometAPI API key from the API keys page. To limit what an assistant can spend, create a dedicated API key for the MCP server: disable Unlimited Quota and set a quota.
- An MCP client that supports remote servers over Streamable HTTP with custom request headers, such as Claude Code or Codex
Connect a client
1
Set the API key
To keep the API key out of configuration files, store it in the
COMETAPI_KEY environment variable. Replace <COMETAPI_KEY> with your CometAPI API key:2
Add the server
- Claude Code
- Codex
- Other clients
Create a Claude Code replaces
.mcp.json file in the project root, which is the directory where you start Claude Code. If the directory already has a .mcp.json file, add the cometapi entry to the mcpServers object of that file. Use this content:${COMETAPI_KEY} with the value of the environment variable, so the file contains no API key. Start Claude Code in the project root from a shell that exports COMETAPI_KEY. When Claude Code asks, approve the cometapi server.3
Verify the connection
Check that the client lists the The result lists models that your API key can access.
cometapi server as connected. In Claude Code and in Codex, the /mcp command shows the server status.Then ask the assistant to search the model catalog. This call is not billed:Try example prompts
To check the accepted parameters before a billed request, use this prompt. The call is not billed:Tools
To check progress or to read a result again, use
get_text_result or get_task. These tools are not billed. Do not call generate_text or generate_image again for that purpose, because a repeated call can start a second billed request.
The client lists generate_text and prepare_text_generation when your API key can access gpt-6-astra. The client lists generate_image and get_task when your API key can access gpt-image-2.
For the parameters, the results, and the errors of each tool, see the tool reference.
Choose the MCP server, the API, or the CLI
The MCP server and the CLI use the same API key, so you can use both. In the CLI, the commands for usage logs and other account data also require an access token.
Billing
Catalog searches, model lookups, receipts, and task reads are not billed.generate_text and generate_image spend your CometAPI balance at the same price as the same request through the CometAPI API. The MCP server adds no fee. For model prices, see the model directory.
The server sends each generation request one time. After a timeout or a disconnect, a request can still complete and be billed. Before you send the request again, check the first request:
To limit what an assistant can spend, use a dedicated API key with a quota. To set a quota or an expiry time through the API, see Create an API key.
Troubleshooting
The server returns 401 with authentication_error
The server returns 401 with authentication_error
Check that
COMETAPI_KEY is set in the environment that starts the client. Then check that the value is a complete CometAPI API key that is enabled, has not expired, and has remaining quota. To copy the API key, open the API keys page. The server does not accept account access tokens.The server returns 403 with authentication_error
The server returns 403 with authentication_error
CometAPI denied access for the API key. Requests through the MCP server do not come from your own IP address, so an IP allowlist on the API key blocks these requests. If the API key has an IP allowlist, create a dedicated API key for the MCP server without an IP allowlist, and set a quota on that API key. Otherwise, check the group permissions of the API key.
The client does not list the generation tools
The client does not list the generation tools
The client lists a generation tool only when your API key can access the model of the tool. To check access, read
gpt-6-astra or gpt-image-2 with get_model_schema. The client lists the generation tools of a model when the result shows schemaStatus as verified.