Providers

Anthropic

Use Claude 3.5 Sonnet, Claude 3 Opus, and more

🟠

Anthropic

Claude 3.5 Sonnet, Claude 3 Opus

Anthropic

Claude models from Anthropic. Known for safety, long context, and excellent reasoning.


Setup

1. Get API Key

Get your API key from console.anthropic.com

2. Add Environment Variable

# .env.local
ANTHROPIC_API_KEY=sk-ant-...

3. Configure Provider

<YourGPTProvider
  runtimeUrl="/api/chat"
  llm={{
    provider: 'anthropic',
    model: 'claude-3-5-sonnet-20241022',
  }}
>
  <CopilotChat />
</YourGPTProvider>

Available Models

ModelContextBest For
claude-3-5-sonnet-20241022200KBest balance of speed & quality
claude-3-opus-20240229200KMost capable, complex tasks
claude-3-sonnet-20240229200KBalanced performance
claude-3-haiku-20240307200KFastest, most affordable

Recommended: Use claude-3-5-sonnet-20241022 for most use cases.


Configuration Options

llm={{
  provider: 'anthropic',
  model: 'claude-3-5-sonnet-20241022',
  temperature: 0.7,        // 0-1
  maxTokens: 4096,         // Max response length
  topP: 1,                 // Nucleus sampling
  topK: 40,                // Top-k sampling
}}

Vision (Image Input)

Claude 3 models support image analysis:

const { sendMessage } = useYourGPT();

sendMessage("Analyze this screenshot", [
  {
    type: 'image',
    data: base64ImageData,
    mimeType: 'image/png',
  }
]);

Long Context

Claude excels at long documents (200K context):

// System prompt can include extensive documentation
<YourGPTProvider
  systemPrompt={`You are a support agent. Here is our full documentation:

  ${fullDocumentation}  // Can be 100K+ tokens

  Answer questions based on this documentation.`}
>

Tool Calling

Claude has robust tool support:

useToolWithSchema({
  name: 'analyze_document',
  description: 'Analyze a document for key insights',
  schema: z.object({
    documentId: z.string(),
    analysisType: z.enum(['summary', 'sentiment', 'entities']),
  }),
  handler: async ({ documentId, analysisType }) => {
    // Claude is excellent at analysis tasks
    const result = await analyzeDocument(documentId, analysisType);
    return { success: true, data: result };
  },
});

Pricing

ModelInputOutput
claude-3-5-sonnet$3/1M tokens$15/1M tokens
claude-3-opus$15/1M tokens$75/1M tokens
claude-3-haiku$0.25/1M tokens$1.25/1M tokens

Check Anthropic pricing for current rates.


Next Steps

On this page