Skip to main content
Use the OpenAI SDK with CometAPI by changing two client settings: the API key and the base URL. Keep your existing OpenAI-compatible request code, then replace the model ID with an available CometAPI model ID.

Install the SDK

The following command installs the OpenAI Python SDK:
The following command installs the OpenAI Node.js SDK:

Python client

The following Python example creates a CometAPI client and sends a chat request:
The response object contains the assistant message:

Node.js client

The following Node.js example uses baseURL with the OpenAI SDK:
The response shape is the same OpenAI-compatible chat completion shape:

Common errors

Last modified on June 23, 2026