Function reference
Chat model providers
Start a chat with a particular large language model (llm) provider.
| ChatAnthropic | Chat with an Anthropic Claude model. | 
| ChatAuto | Chat with any provider. | 
| ChatAzureOpenAI | Chat with a model hosted on Azure OpenAI. | 
| ChatBedrockAnthropic | Chat with an AWS bedrock model. | 
| ChatCloudflare | Chat with a model hosted on Cloudflare Workers AI. | 
| ChatDatabricks | Chat with a model hosted on Databricks. | 
| ChatDeepSeek | Chat with a model hosted on DeepSeek. | 
| ChatGithub | Chat with a model hosted on the GitHub model marketplace. | 
| ChatGoogle | Chat with a Google Gemini model. | 
| ChatGroq | Chat with a model hosted on Groq. | 
| ChatHuggingFace | Chat with a model hosted on Hugging Face Inference API. | 
| ChatMistral | Chat with a model hosted on Mistral’s La Plateforme. | 
| ChatOllama | Chat with a local Ollama model. | 
| ChatOpenAI | Chat with an OpenAI model. | 
| ChatOpenRouter | Chat with one of the many models hosted on OpenRouter. | 
| ChatPerplexity | Chat with a model hosted on perplexity.ai. | 
| ChatPortkey | Chat with a model hosted on PortkeyAI | 
| ChatSnowflake | Chat with a Snowflake Cortex LLM | 
| ChatVertex | Chat with a Google Vertex AI model. | 
The chat object
Methods and attributes available on a chat instance
| Chat | A chat object that can be used to interact with a language model. | 
Image input
Submit image input to the chat
| content_image_file | Encode image content from a file for chat input. | 
| content_image_plot | Encode the current matplotlib plot as an image for chat input. | 
| content_image_url | Encode image content from a URL for chat input. | 
PDF input
Submit pdf input to the chat
| content_pdf_file | Prepare a local PDF for input to a chat. | 
| content_pdf_url | Use a remote PDF for input to a chat. | 
Tool calling
Add context to python function before registering it as a tool.
| Tool | Define a tool | 
| ToolRejectError | Error to represent a tool call being rejected. | 
Batch chat
Submit multiple chats in one batch
| batch_chat | Submit multiple chat requests in a batch. | 
| batch_chat_text | Submit multiple chat requests in a batch and return text responses. | 
| batch_chat_structured | Submit multiple structured data requests in a batch. | 
| batch_chat_completed | Check if a batch job is completed without waiting. | 
Prompt interpolation
Interpolate variables into prompt templates
| interpolate | Interpolate variables into a prompt | 
| interpolate_file | Interpolate variables into a prompt from a file | 
Turns
A provider-agnostic representation of content generated during an assistant/user turn.
| Turn | A user or assistant turn | 
Query token usage
| token_usage | Report on token usage in the current session | 
Implement a model provider
| Provider | A model provider interface for a Chat. | 
User-facing types
| types.Content | Base class for all content types that can be appear in a Turn | 
| types.ContentImage | Base class for image content. | 
| types.ContentImageInline | Inline image content. | 
| types.ContentImageRemote | Image content from a URL. | 
| types.ContentJson | JSON content | 
| types.ContentText | Text content for a Turn | 
| types.ContentToolRequest | A request to call a tool/function | 
| types.ContentToolResult | The result of calling a tool/function | 
| types.ChatResponse | Chat response object. | 
| types.ChatResponseAsync | Chat response (async) object. | 
| types.ImageContentTypes | Allowable content types for images. | 
| types.MISSING_TYPE | A singleton representing a missing value. | 
| types.MISSING | |
| types.SubmitInputArgsT | A TypedDict representing the provider specific arguments that can specified when | 
| types.TokenUsage | Token usage for a given provider (name). | 
| types.ToolAnnotations | Additional properties describing a Tool to clients. | 
| types.ToolInfo | Serializable tool information |