Look something up
Model providers
Look up the classes and environment variables of coco_openai and coco_anthropic, and how each handles retries, timeouts and rate limits.
Look up coco_openai and coco_anthropic.
coco_openai
From the trustcoco-openai distribution, or the openai extra of coco-framework.
from coco_openai import (
ChatOpenAI,
AzureChatOpenAI,
OpenAI,
AzureOpenAI,
OpenAIEmbeddings,
AzureOpenAIEmbeddings,
custom_tool,
StreamChunkTimeoutError,
)ChatOpenAI supports the Chat Completions API, the Responses API, and any OpenAI-compatible endpoint through base_url.
| Variable | Description |
|---|---|
OPENAI_API_KEY | The OpenAI API key. |
OPENAI_BASE_URL, OPENAI_API_BASE | An OpenAI-compatible endpoint, such as vLLM, Ollama, LiteLLM, or an internal gateway. |
OPENAI_ORG_ID, OPENAI_PROJECT_ID | Optional organization and project. |
AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, OPENAI_API_VERSION | Azure OpenAI credentials. |
- Retries:
ChatOpenAIretries HTTP 429 and 5xx errors up tomax_retriestimes, 2 by default, with exponential backoff. - Streaming timeouts: A streamed call raises
StreamChunkTimeoutErrorwhen a chunk is late. - Across providers: Combine
ModelRetryMiddlewareandModelFallbackMiddleware. See Retries and fallbacks.
Keep in mind: For models whose names start with gpt-6, a call with tools uses the Responses API, so the endpoint must serve /v1/responses.
coco_anthropic
From the trustcoco-anthropic distribution, or the anthropic extra of coco-framework.
from coco_anthropic import (
ChatAnthropic,
AnthropicLLM,
convert_to_anthropic_tool,
)ChatAnthropic supports Claude models, extended thinking, prompt caching, and native tool use.
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | The Anthropic API key. |
ANTHROPIC_API_URL | An optional custom endpoint. |
See Models for examples.