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
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.
Make a completion call
Use the
cometapi/<model-name> format to specify models. You can pass the key via environment variable or explicitly:Tips and troubleshooting
Tips and troubleshooting
- 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, andtop_p— add them to anycompletion()call, e.g.completion(..., temperature=0.7). - Error handling: Wrap calls in
try/exceptto 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 documentation — CometAPI quick start