Claude Anthropic
Updated
Use Anthropic Claude as the LLM in a Conversational AI Platform agent.
Preview documentation
Claude from Anthropic provides helpful, harmless, and honest AI assistance with strong reasoning capabilities and natural conversational abilities.
Sample configuration
The following example shows how to configure Claude as the agent's LLM when you create or update an agent. For a complete example, see Create an agent and start a session.
Claude supports BYOK only. It isn't available in managed mode. Store your Anthropic API key in a secret set, and refer to it from the agent. For details, see Use your own provider keys.
from agora_agent import Agent, Anthropic, secret_ref
# client is your configured Agora client
agent = (
Agent(client=client)
.with_stt(...) # configure your ASR vendor
.with_llm(
Anthropic(
api_key=secret_ref("support_prod", "anthropic"),
vendor="anthropic",
url="https://api.anthropic.com/v1/messages",
headers={"anthropic-version": "2023-06-01"},
model="claude-opus-4-8",
max_tokens=1024,
max_history=32,
failure_message="Please hold on a second.",
system_messages=[
{"role": "system", "content": "You are a friendly support agent for Acme. Keep your answers short."}
],
)
)
.with_tts(...) # configure your TTS vendor
)import { Agent, Anthropic, secretRef } from 'agora-agents';
// client is your configured Agora client
const agent = new Agent({ client })
.withStt(/* configure your ASR vendor */)
.withLlm(
new Anthropic({
apiKey: secretRef('support_prod', 'anthropic'),
vendor: 'anthropic',
url: 'https://api.anthropic.com/v1/messages',
headers: { 'anthropic-version': '2023-06-01' },
model: 'claude-opus-4-8',
maxTokens: 1024,
maxHistory: 32,
failureMessage: 'Please hold on a second.',
systemMessages: [
{ role: 'system', content: 'You are a friendly support agent for Acme. Keep your answers short.' },
],
}),
)
.withTts(/* configure your TTS vendor */);// client is your configured Agora client
maxTokens, maxHistory := 1024, 32
agent := agentkit.NewAgent(client).
WithStt( /* configure your ASR vendor */ ).
WithLlm(vendors.NewAnthropic(vendors.AnthropicOptions{
APIKey: agentkit.SecretRef("support_prod", "anthropic"),
Vendor: "anthropic",
URL: "https://api.anthropic.com/v1/messages",
Headers: map[string]string{"anthropic-version": "2023-06-01"},
Model: "claude-opus-4-8",
MaxTokens: &maxTokens,
MaxHistory: &maxHistory,
FailureMessage: "Please hold on a second.",
SystemMessages: []map[string]interface{}{
{"role": "system", "content": "You are a friendly support agent for Acme. Keep your answers short."},
},
})).
WithTts( /* configure your TTS vendor */ )Set credential.mode to byok and credential.fields.api_key to a reference to the key. In the following example, the key is stored as anthropic in the support_prod set:
"llm": {
"credential": {
"mode": "byok",
"fields": {
"api_key": "$secrets.support_prod.anthropic"
}
},
"vendor": "anthropic",
"style": "anthropic",
"model": "claude-opus-4-8",
"url": "https://api.anthropic.com/v1/messages",
"headers": {
"anthropic-version": "2023-06-01"
},
"max_history": 32,
"failure_message": "Please hold on a second.",
"params": {
"max_tokens": 1024
}
}Set the system prompt and the greeting with the agent's instructions and greeting, not in the llm block.
Key parameters
The llm block takes the following fields. In the SDKs, the LLM class sets them from its options. Use the Anthropic class. The SDK sets the style to anthropic and sends max_tokens in params.
vendorstringSet to anthropic.
credentialobjectSet mode to byok and fields.api_key to a $secrets.<set>.<key> reference to your Anthropic API key. Get your API key from the Anthropic Console.
stylestringSet to anthropic to use Claude's message format.
modelstringRefer to Claude models for available models.
urlstringUse Anthropic's messages endpoint.
headersobjectMust include the anthropic-version header for API compatibility.
paramsobjectmax_tokensintegerThe maximum number of tokens to generate in the response.
For complete llm block options, see Create an agent. For Claude-specific options and model capabilities, see the Claude API documentation.
