acompletion
is the asynchronous version of completion
.
stream=True
enables streaming, where the response is yielded in real-time chunks.
Use asyncio
to run the function (e.g., in a Jupyter Notebook with await
or via asyncio.run()
in scripts).
If an error occurs, it's caught and printed for debugging.
Supported Models: CometAPI models follow the format cometapi/<model-name>
, e.g., cometapi/gpt-5
, cometapi/gpt-4o
, cometapi/chatgpt-4o-latest
. Check the CometAPI documentation for the latest models.
Error Handling: Always wrap calls in try-except blocks to handle issues like invalid keys or network errors.
Advanced Features: LiteLLM supports parameters like temperature
, max_tokens
, and top_p
for fine-tuning responses. Add them to the completion
or acompletion
calls, e.g., completion(..., temperature=0.7)
.
Security: Never commit your API key to version control. Use environment variables or secret managers.
Troubleshooting: If you encounter issues, ensure your API key is valid and check LiteLLM's logs. For more details, refer to the LiteLLM Documentation or CometAPI Doc. Rate Limits and Costs: Monitor your API usage in the CometAPI console.