Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions integrations/llms/anthropic.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: "Anthropic"
description: "Integrate Anthropic's Claude models with Portkey's AI Gateway"

Check warning on line 3 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L3

Did you really mean 'Anthropic's'?

Check warning on line 3 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L3

Did you really mean 'Portkey's'?
---

Portkey provides a robust and secure gateway to integrate various Large Language Models (LLMs) into applications, including [Anthropic's Claude APIs](https://docs.anthropic.com/claude/reference/getting-started-with-the-api).

Check warning on line 6 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L6

Did you really mean 'Portkey'?

Check warning on line 6 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L6

Did you really mean 'LLMs'?

With Portkey, take advantage of features like fast AI gateway access, observability, prompt management, and more, while securely managing API keys through [Model Catalog](/product/model-catalog).

Check warning on line 8 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L8

Did you really mean 'Portkey'?


<CardGroup cols={3}>
Expand Down Expand Up @@ -225,7 +225,7 @@

### System Prompts

Anthropic handles system prompts differently than OpenAI. With Portkey, you can use the OpenAI-compatible format:

Check warning on line 228 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L228

Did you really mean 'Portkey'?

<CodeGroup>
```python Python icon="python"
Expand All @@ -251,7 +251,7 @@
```
</CodeGroup>

Portkey automatically formats this for Anthropic's API.

Check warning on line 254 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L254

Did you really mean 'Portkey'?

Check warning on line 254 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L254

Did you really mean 'Anthropic's'?

### Streaming

Expand Down Expand Up @@ -289,9 +289,9 @@

## Advanced Features

### Vision (Multimodal)

Check warning on line 292 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L292

Did you really mean 'Multimodal'?

Portkey supports Anthropic's vision models including `claude-sonnet-4-5-20250929`, `claude-3-5-sonnet`, `claude-3-haiku`, `claude-3-opus`, and `claude-3.7-sonnet`. Use the same format as OpenAI:

Check warning on line 294 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L294

Did you really mean 'Portkey'?

Check warning on line 294 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L294

Did you really mean 'Anthropic's'?

<Note>
Anthropic **only accepts base64-encoded images** and does not support image URLs. Use the same base64 format to send images to both Anthropic and OpenAI models.
Expand Down Expand Up @@ -359,7 +359,7 @@

### PDF Support

Anthropic Claude processes PDFs to extract text, analyze charts, and understand visual content. PDF support is available on:

Check warning on line 362 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L362

Did you really mean 'PDFs'?
- Claude 3.7 Sonnet (`claude-3-7-sonnet-20250219`)
- Claude 3.5 Sonnet (`claude-3-5-sonnet-20241022`, `claude-3-5-sonnet-20240620`)
- Claude Sonnet 4-5 (`claude-sonnet-4-5-20250929`)
Expand All @@ -380,7 +380,7 @@

# Fetch and encode the PDF
pdf_url = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
pdf_data = "data:application/pdf;base64," + base64.standard_b64encode(httpx.get(pdf_url).content).decode("utf-8")
pdf_data = base64.standard_b64encode(httpx.get(pdf_url).content).decode("utf-8")

response = portkey.chat.completions.create(
model="@anthropic/claude-sonnet-4-5-20250929",
Expand Down Expand Up @@ -412,7 +412,6 @@
const pdfUrl = "https://assets.anthropic.com/m/1cd9d098ac3e6467/original/Claude-3-Model-Card-October-Addendum.pdf"
const pdfResponse = await axios.get(pdfUrl, { responseType: 'arraybuffer' })
const pdfBase64 = Buffer.from(pdfResponse.data).toString('base64')
const pdfData = `data:application/pdf;base64,${pdfBase64}`

const response = await portkey.chat.completions.create({
model: "@anthropic/claude-sonnet-4-5-20250929",
Expand All @@ -423,7 +422,7 @@
role: "user",
content: [
{ type: "text", text: "What are the key findings in this document?" },
{ type: "file", file: { mime_type: "application/pdf", file_data: pdfData } }
{ type: "file", file: { mime_type: "application/pdf", file_data: pdfBase64 } }
]
}
]
Expand Down Expand Up @@ -497,9 +496,9 @@

### Using /messages Route

Portkey supports Anthropic's `/messages` endpoint, allowing you to use either Anthropic's native SDK or Portkey's SDK with full gateway features.

Check warning on line 499 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L499

Did you really mean 'Portkey'?

Check warning on line 499 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L499

Did you really mean 'Anthropic's'?

Check warning on line 499 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L499

Did you really mean 'Portkey's'?

#### Using Anthropic's Native SDK

Check warning on line 501 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L501

Did you really mean 'Anthropic's'?

<CodeGroup>
```python Anthropic Py
Expand Down Expand Up @@ -537,7 +536,7 @@
```
</CodeGroup>

#### Using Portkey's SDK

Check warning on line 539 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L539

Did you really mean 'Portkey's'?

```sh cURL icon="square-terminal"
curl --location 'https://api.portkey.ai/v1/messages' \
Expand All @@ -563,7 +562,7 @@

### Prompt Caching

Portkey works with Anthropic's prompt caching feature to save time and money. Refer to this guide:

Check warning on line 565 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L565

Did you really mean 'Portkey'?

<Card title="Prompt Caching" href="/integrations/llms/anthropic/prompt-caching">
Learn how to enable prompt caching for Anthropic requests
Expand All @@ -571,7 +570,7 @@

### Beta Features

Portkey supports Anthropic's beta features through headers. Pass the beta feature name as the value:

Check warning on line 573 in integrations/llms/anthropic.mdx

View check run for this annotation

Mintlify / Mintlify Validation (portkey-docs) - vale-spellcheck

integrations/llms/anthropic.mdx#L573

Did you really mean 'Anthropic's'?

<CodeGroup>
```python Python icon="python"
Expand Down
Loading