Skip to main content
LiteLLM provides a unified Python API for 100+ LLM providers. CometAPI is natively supported — use the cometapi/ prefix to route requests through CometAPI’s model catalog.

Prerequisites

  • Python 3.6+
  • A CometAPI account with an active API key — get yours here
1

Install LiteLLM

2

Set your API key

Set the API key as an environment variable (recommended) or pass it inline:
Use environment variables to avoid hardcoding sensitive credentials in your scripts.
3

Make a completion call

Use the cometapi/<model-name> format to specify models. You can pass the key via environment variable or explicitly:
4

Async and streaming calls

Use acompletion with stream=True for non-blocking, real-time responses:
  • Model format: CometAPI models use the prefix cometapi/<model-name>, e.g. cometapi/your-model-id. See the CometAPI Models page for available models.
  • Fine-tuning responses: LiteLLM supports temperature, max_tokens, and top_p — add them to any completion() call, e.g. completion(..., temperature=0.7).
  • Error handling: Wrap calls in try/except to catch invalid key errors or network issues.
  • Security: Never commit API keys to version control. Use environment variables or a secrets manager.
  • Rate limits: Monitor usage in the CometAPI console.
  • More docs: LiteLLM documentationCometAPI quick start