Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

docs(anthropic.md): update docs with file message usage

Krrish Dholakiab0fa934fe33c
diff --git a/docs/my-website/docs/providers/anthropic.md b/docs/my-website/docs/providers/anthropic.md
index 55e9ba10d38..09ed7887816 100644
--- a/docs/my-website/docs/providers/anthropic.md
+++ b/docs/my-website/docs/providers/anthropic.md
@@ -1035,8 +1035,10 @@ response = completion(
"content": [
{"type": "text", "text": "You are a very professional document summarization specialist. Please summarize the given document."},
{
- "type": "image_url",
- "image_url": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
+ "type": "file",
+ "file": {
+ "file_data": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
+ }
},
],
}
@@ -1081,8 +1083,10 @@ curl http://0.0.0.0:4000/v1/chat/completions \
"text": "You are a very professional document summarization specialist. Please summarize the given document"
},
{
- "type": "image_url",
- "image_url": "data:application/pdf;base64,{encoded_file}" # 👈 PDF
+ "type": "file",
+ "file": {
+ "file_data": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
+ }
}
}
]
diff --git a/docs/my-website/docs/providers/bedrock.md b/docs/my-website/docs/providers/bedrock.md
index 95e0c90bd73..bfb60e42c77 100644
--- a/docs/my-website/docs/providers/bedrock.md
+++ b/docs/my-website/docs/providers/bedrock.md
@@ -1168,14 +1168,22 @@ os.environ["AWS_REGION_NAME"] = ""
# pdf url
image_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
+# Download the file
+response = requests.get(url)
+file_data = response.content
+
+encoded_file = base64.b64encode(file_data).decode("utf-8")
+
# model
model = "bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0"
image_content = [
{"type": "text", "text": "What's this file about?"},
{
- "type": "image_url",
- "image_url": image_url, # OR {"url": image_url}
+ "type": "file",
+ "file": {
+ "file_data": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
+ }
},
]
@@ -1221,8 +1229,10 @@ curl -X POST 'http://0.0.0.0:4000/chat/completions' \
"messages": [
{"role": "user", "content": {"type": "text", "text": "What's this file about?"}},
{
- "type": "image_url",
- "image_url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
+ "type": "file",
+ "file": {
+ "file_data": f"data:application/pdf;base64,{encoded_file}", # 👈 PDF
+ }
}
]
}'