Implementation:Elevenlabs Elevenlabs python CustomLlm
| Field | Value |
|---|---|
| source | Elevenlabs_Elevenlabs_python |
| domains | Conversational AI, Custom LLM, API Integration |
| last_updated | 2026-02-15 |
Overview
Description
CustomLlm is a Pydantic model that defines the configuration for integrating a custom LLM endpoint with an ElevenLabs conversational AI agent. It allows developers to use their own Chat Completions-compatible endpoint instead of the built-in LLM options, providing flexibility to use self-hosted or third-party language models.
This model is auto-generated by Fern from the ElevenLabs API definition and inherits from UncheckedBaseModel. It supports authentication via API keys, custom request headers, API versioning, and multiple API types (chat completions or responses).
Usage
CustomLlm is used within PromptAgentApiModelInput when the agent's LLM is set to CUSTOM_LLM. It enables the agent to route LLM requests to a user-specified endpoint, such as an Azure OpenAI deployment, a self-hosted model, or any Chat Completions-compatible service.
Code Reference
Source Location
src/elevenlabs/types/custom_llm.py
Class Signature
class CustomLlm(UncheckedBaseModel):
...
Import Statement
from elevenlabs.types import CustomLlm
I/O Contract
| Field | Type | Required | Description |
|---|---|---|---|
url |
str |
Yes | The URL of the Chat Completions compatible endpoint. |
model_id |
Optional[str] |
No | The model ID to be used if URL serves multiple models. |
api_key |
Optional[ConvAiSecretLocator] |
No | The API key for authentication. |
request_headers |
Optional[Dict[str, CustomLlmRequestHeadersValue]] |
No | Headers that should be included in the request. |
api_version |
Optional[str] |
No | The API version to use for the request. |
api_type |
Optional[CustomLlmapiType] |
No | The API type to use (chat_completions or responses). |
Usage Examples
Basic Custom LLM Configuration
from elevenlabs.types import CustomLlm
custom_llm = CustomLlm(
url="https://my-llm-service.example.com/v1/chat/completions",
model_id="my-fine-tuned-model",
)
Custom LLM with Azure OpenAI
from elevenlabs.types import CustomLlm
custom_llm = CustomLlm(
url="https://my-deployment.openai.azure.com/openai/deployments/gpt-4/chat/completions",
api_version="2024-02-15-preview",
)
Using Custom LLM in Agent Prompt Config
from elevenlabs.types import PromptAgentApiModelInput, CustomLlm
prompt_config = PromptAgentApiModelInput(
prompt="You are a helpful assistant powered by a custom model.",
custom_llm=CustomLlm(
url="https://api.example.com/v1/chat/completions",
model_id="custom-model-v2",
),
)
Related Pages
- Elevenlabs_Elevenlabs_python_PromptAgentApiModelInput - Parent prompt configuration that references CustomLlm
- Elevenlabs_Elevenlabs_python_AgentConfig - Core agent configuration
- Elevenlabs_Elevenlabs_python_GetAgentResponseModel - Full agent response model