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]

[Feat] New model - add bedrock writer models (#17685)

Ishaan Jaffa904067d389f
diff --git a/docs/my-website/docs/providers/bedrock_writer.md b/docs/my-website/docs/providers/bedrock_writer.md
new file mode 100644
index 00000000000..00d77a37f44
--- /dev/null
+++ b/docs/my-website/docs/providers/bedrock_writer.md
@@ -0,0 +1,316 @@
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+# Bedrock - Writer Palmyra
+
+## Overview
+
+| Property | Details |
+|-------|-------|
+| Description | Writer Palmyra X5 and X4 foundation models on Amazon Bedrock, offering advanced reasoning, tool calling, and document processing capabilities |
+| Provider Route on LiteLLM | `bedrock/` |
+| Supported Operations | `/chat/completions` |
+| Link to Provider Doc | [Writer on AWS Bedrock ↗](https://aws.amazon.com/bedrock/writer/) |
+
+## Quick Start
+
+### LiteLLM SDK
+
+```python showLineNumbers title="SDK Usage"
+import litellm
+import os
+
+os.environ["AWS_ACCESS_KEY_ID"] = ""
+os.environ["AWS_SECRET_ACCESS_KEY"] = ""
+os.environ["AWS_REGION_NAME"] = "us-west-2"
+
+response = litellm.completion(
+ model="bedrock/us.writer.palmyra-x5-v1:0",
+ messages=[{"role": "user", "content": "Hello, how are you?"}]
+)
+
+print(response.choices[0].message.content)
+```
+
+### LiteLLM Proxy
+
+**1. Setup config.yaml**
+
+```yaml showLineNumbers title="proxy_config.yaml"
+model_list:
+ - model_name: writer-palmyra-x5
+ litellm_params:
+ model: bedrock/us.writer.palmyra-x5-v1:0
+ aws_access_key_id: os.environ/AWS_ACCESS_KEY_ID
+ aws_secret_access_key: os.environ/AWS_SECRET_ACCESS_KEY
+ aws_region_name: us-west-2
+```
+
+**2. Start the proxy**
+
+```bash showLineNumbers title="Start Proxy"
+litellm --config config.yaml
+```
+
+**3. Call the proxy**
+
+<Tabs>
+<TabItem value="curl" label="curl">
+
+```bash showLineNumbers title="curl Request"
+curl -X POST http://localhost:4000/v1/chat/completions \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer sk-1234" \
+ -d '{
+ "model": "writer-palmyra-x5",
+ "messages": [{"role": "user", "content": "Hello, how are you?"}]
+ }'
+```
+
+</TabItem>
+<TabItem value="openai-sdk" label="OpenAI SDK">
+
+```python showLineNumbers title="OpenAI SDK"
+from openai import OpenAI
+
+client = OpenAI(
+ api_key="sk-1234",
+ base_url="http://localhost:4000/v1"
+)
+
+response = client.chat.completions.create(
+ model="writer-palmyra-x5",
+ messages=[{"role": "user", "content": "Hello, how are you?"}]
+)
+
+print(response.choices[0].message.content)
+```
+
+</TabItem>
+</Tabs>
+
+## Tool Calling
+
+Writer Palmyra models support multi-step tool calling for complex workflows.
+
+### LiteLLM SDK
+
+```python showLineNumbers title="Tool Calling - SDK"
+import litellm
+
+tools = [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather in a location",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "location": {
+ "type": "string",
+ "description": "The city and state"
+ }
+ },
+ "required": ["location"]
+ }
+ }
+ }
+]
+
+response = litellm.completion(
+ model="bedrock/us.writer.palmyra-x5-v1:0",
+ messages=[{"role": "user", "content": "What's the weather in Boston?"}],
+ tools=tools
+)
+```
+
+### LiteLLM Proxy
+
+<Tabs>
+<TabItem value="curl" label="curl">
+
+```bash showLineNumbers title="Tool Calling - curl"
+curl -X POST http://localhost:4000/v1/chat/completions \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer sk-1234" \
+ -d '{
+ "model": "writer-palmyra-x5",
+ "messages": [{"role": "user", "content": "What'\''s the weather in Boston?"}],
+ "tools": [{
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather in a location",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "location": {"type": "string", "description": "The city and state"}
+ },
+ "required": ["location"]
+ }
+ }
+ }]
+ }'
+```
+
+</TabItem>
+<TabItem value="openai-sdk" label="OpenAI SDK">
+
+```python showLineNumbers title="Tool Calling - OpenAI SDK"
+from openai import OpenAI
+
+client = OpenAI(
+ api_key="sk-1234",
+ base_url="http://localhost:4000/v1"
+)
+
+tools = [
+ {
+ "type": "function",
+ "function": {
+ "name": "get_weather",
+ "description": "Get the current weather in a location",
+ "parameters": {
+ "type": "object",
+ "properties": {
+ "location": {
+ "type": "string",
+ "description": "The city and state"
+ }
+ },
+ "required": ["location"]
+ }
+ }
+ }
+]
+
+response = client.chat.completions.create(
+ model="writer-palmyra-x5",
+ messages=[{"role": "user", "content": "What's the weather in Boston?"}],
+ tools=tools
+)
+```
+
+</TabItem>
+</Tabs>
+
+## Document Input
+
+Writer Palmyra models support document inputs including PDFs.
+
+### LiteLLM SDK
+
+```python showLineNumbers title="PDF Document Input - SDK"
+import litellm
+import base64
+
+# Read and encode PDF
+with open("document.pdf", "rb") as f:
+ pdf_base64 = base64.b64encode(f.read()).decode("utf-8")
+
+response = litellm.completion(
+ model="bedrock/us.writer.palmyra-x5-v1:0",
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "image_url",
+ "image_url": {
+ "url": f"data:application/pdf;base64,{pdf_base64}"
+ }
+ },
+ {
+ "type": "text",
+ "text": "Summarize this document"
+ }
+ ]
+ }
+ ]
+)
+```
+
+### LiteLLM Proxy
+
+<Tabs>
+<TabItem value="curl" label="curl">
+
+```bash showLineNumbers title="PDF Document Input - curl"
+# First, base64 encode your PDF
+PDF_BASE64=$(base64 -i document.pdf)
+
+curl -X POST http://localhost:4000/v1/chat/completions \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer sk-1234" \
+ -d '{
+ "model": "writer-palmyra-x5",
+ "messages": [{
+ "role": "user",
+ "content": [
+ {
+ "type": "image_url",
+ "image_url": {"url": "data:application/pdf;base64,'$PDF_BASE64'"}
+ },
+ {
+ "type": "text",
+ "text": "Summarize this document"
+ }
+ ]
+ }]
+ }'
+```
+
+</TabItem>
+<TabItem value="openai-sdk" label="OpenAI SDK">
+
+```python showLineNumbers title="PDF Document Input - OpenAI SDK"
+from openai import OpenAI
+import base64
+
+client = OpenAI(
+ api_key="sk-1234",
+ base_url="http://localhost:4000/v1"
+)
+
+# Read and encode PDF
+with open("document.pdf", "rb") as f:
+ pdf_base64 = base64.b64encode(f.read()).decode("utf-8")
+
+response = client.chat.completions.create(
+ model="writer-palmyra-x5",
+ messages=[
+ {
+ "role": "user",
+ "content": [
+ {
+ "type": "image_url",
+ "image_url": {
+ "url": f"data:application/pdf;base64,{pdf_base64}"
+ }
+ },
+ {
+ "type": "text",
+ "text": "Summarize this document"
+ }
+ ]
+ }
+ ]
+)
+```
+
+</TabItem>
+</Tabs>
+
+## Supported Models
+
+| Model ID | Context Window | Input Cost (per 1K tokens) | Output Cost (per 1K tokens) |
+|----------|---------------|---------------------------|----------------------------|
+| `bedrock/us.writer.palmyra-x5-v1:0` | 1M tokens | $0.0006 | $0.006 |
+| `bedrock/us.writer.palmyra-x4-v1:0` | 128K tokens | $0.0025 | $0.010 |
+| `bedrock/writer.palmyra-x5-v1:0` | 1M tokens | $0.0006 | $0.006 |
+| `bedrock/writer.palmyra-x4-v1:0` | 128K tokens | $0.0025 | $0.010 |
+
+:::info Cross-Region Inference
+The `us.writer.*` model IDs use cross-region inference profiles. Use these for production workloads.
+:::
diff --git a/docs/my-website/sidebars.js b/docs/my-website/sidebars.js
index 21fda61c3f6..3efad0a9ab1 100644
--- a/docs/my-website/sidebars.js
+++ b/docs/my-website/sidebars.js
@@ -651,6 +651,7 @@ const sidebars = {
"providers/bedrock_rerank",
"providers/bedrock_agentcore",
"providers/bedrock_agents",
+ "providers/bedrock_writer",
"providers/bedrock_batches",
"providers/bedrock_vector_store",
]
diff --git a/litellm/constants.py b/litellm/constants.py
index ed5fee78462..2c982ee41c4 100644
--- a/litellm/constants.py
+++ b/litellm/constants.py
@@ -938,6 +938,8 @@ BEDROCK_CONVERSE_MODELS = [
"amazon.nova-lite-v1:0",
"amazon.nova-2-lite-v1:0",
"amazon.nova-pro-v1:0",
+ "writer.palmyra-x4-v1:0",
+ "writer.palmyra-x5-v1:0",
]
diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.json
index 8ba4744d45a..ca438b5fd24 100644
--- a/litellm/model_prices_and_context_window_backup.json
+++ b/litellm/model_prices_and_context_window_backup.json
@@ -255,6 +255,50 @@
"mode": "image_generation",
"output_cost_per_image": 0.06
},
+ "us.writer.palmyra-x4-v1:0": {
+ "input_cost_per_token": 2.5e-06,
+ "litellm_provider": "bedrock_converse",
+ "max_input_tokens": 128000,
+ "max_output_tokens": 8192,
+ "max_tokens": 8192,
+ "mode": "chat",
+ "output_cost_per_token": 1e-05,
+ "supports_function_calling": true,
+ "supports_pdf_input": true
+ },
+ "us.writer.palmyra-x5-v1:0": {
+ "input_cost_per_token": 6e-07,
+ "litellm_provider": "bedrock_converse",
+ "max_input_tokens": 1000000,
+ "max_output_tokens": 8192,
+ "max_tokens": 8192,
+ "mode": "chat",
+ "output_cost_per_token": 6e-06,
+ "supports_function_calling": true,
+ "supports_pdf_input": true
+ },
+ "writer.palmyra-x4-v1:0": {
+ "input_cost_per_token": 2.5e-06,
+ "litellm_provider": "bedrock_converse",
+ "max_input_tokens": 128000,
+ "max_output_tokens": 8192,
+ "max_tokens": 8192,
+ "mode": "chat",
+ "output_cost_per_token": 1e-05,
+ "supports_function_calling": true,
+ "supports_pdf_input": true
+ },
+ "writer.palmyra-x5-v1:0": {
+ "input_cost_per_token": 6e-07,
+ "litellm_provider": "bedrock_converse",
+ "max_input_tokens": 1000000,
+ "max_output_tokens": 8192,
+ "max_tokens": 8192,
+ "mode": "chat",
+ "output_cost_per_token": 6e-06,
+ "supports_function_calling": true,
+ "supports_pdf_input": true
+ },
"amazon.nova-lite-v1:0": {
"input_cost_per_token": 6e-08,
"litellm_provider": "bedrock_converse",
diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.json
index 8ba4744d45a..ca438b5fd24 100644
--- a/model_prices_and_context_window.json
+++ b/model_prices_and_context_window.json
@@ -255,6 +255,50 @@
"mode": "image_generation",
"output_cost_per_image": 0.06
},
+ "us.writer.palmyra-x4-v1:0": {
+ "input_cost_per_token": 2.5e-06,
+ "litellm_provider": "bedrock_converse",
+ "max_input_tokens": 128000,
+ "max_output_tokens": 8192,
+ "max_tokens": 8192,
+ "mode": "chat",
+ "output_cost_per_token": 1e-05,
+ "supports_function_calling": true,
+ "supports_pdf_input": true
+ },
+ "us.writer.palmyra-x5-v1:0": {
+ "input_cost_per_token": 6e-07,
+ "litellm_provider": "bedrock_converse",
+ "max_input_tokens": 1000000,
+ "max_output_tokens": 8192,
+ "max_tokens": 8192,
+ "mode": "chat",
+ "output_cost_per_token": 6e-06,
+ "supports_function_calling": true,
+ "supports_pdf_input": true
+ },
+ "writer.palmyra-x4-v1:0": {
+ "input_cost_per_token": 2.5e-06,
+ "litellm_provider": "bedrock_converse",
+ "max_input_tokens": 128000,
+ "max_output_tokens": 8192,
+ "max_tokens": 8192,
+ "mode": "chat",
+ "output_cost_per_token": 1e-05,
+ "supports_function_calling": true,
+ "supports_pdf_input": true
+ },
+ "writer.palmyra-x5-v1:0": {
+ "input_cost_per_token": 6e-07,
+ "litellm_provider": "bedrock_converse",
+ "max_input_tokens": 1000000,
+ "max_output_tokens": 8192,
+ "max_tokens": 8192,
+ "mode": "chat",
+ "output_cost_per_token": 6e-06,
+ "supports_function_calling": true,
+ "supports_pdf_input": true
+ },
"amazon.nova-lite-v1:0": {
"input_cost_per_token": 6e-08,
"litellm_provider": "bedrock_converse",
diff --git a/tests/test_litellm/llms/bedrock/chat/test_writer_palmyra.py b/tests/test_litellm/llms/bedrock/chat/test_writer_palmyra.py
new file mode 100644
index 00000000000..9bc6724867f
--- /dev/null
+++ b/tests/test_litellm/llms/bedrock/chat/test_writer_palmyra.py
@@ -0,0 +1,69 @@
+"""
+Tests for Writer Palmyra X5 and X4 models on Bedrock Converse.
+"""
+
+import os
+import sys
+
+import pytest
+
+sys.path.insert(
+ 0, os.path.abspath("../../../../..")
+) # Adds the parent directory to the system path
+
+
+from litellm.llms.bedrock.common_utils import BedrockModelInfo
+
+
+def test_writer_palmyra_routes_to_converse():
+ """
+ Test that Writer Palmyra models route to converse API.
+ """
+ bedrock_model_info = BedrockModelInfo
+
+ # Test base model routes to converse
+ bedrock_route = bedrock_model_info.get_bedrock_route(
+ model="bedrock/writer.palmyra-x5-v1:0"
+ )
+ assert bedrock_route == "converse"
+
+ bedrock_route = bedrock_model_info.get_bedrock_route(
+ model="bedrock/writer.palmyra-x4-v1:0"
+ )
+ assert bedrock_route == "converse"
+
+
+def test_writer_palmyra_cross_region_routes_to_converse():
+ """
+ Test that Writer Palmyra models with cross-region inference prefix route to converse API.
+ """
+ bedrock_model_info = BedrockModelInfo
+
+ # Test cross-region inference profile routes to converse
+ bedrock_route = bedrock_model_info.get_bedrock_route(
+ model="bedrock/us.writer.palmyra-x5-v1:0"
+ )
+ assert bedrock_route == "converse"
+
+ bedrock_route = bedrock_model_info.get_bedrock_route(
+ model="bedrock/us.writer.palmyra-x4-v1:0"
+ )
+ assert bedrock_route == "converse"
+
+
+def test_writer_palmyra_base_model_extraction():
+ """
+ Test that base model is correctly extracted from Writer Palmyra cross-region models.
+ """
+ bedrock_model_info = BedrockModelInfo
+
+ # Test us. prefix is stripped correctly
+ base_model = bedrock_model_info.get_base_model(
+ model="bedrock/us.writer.palmyra-x5-v1:0"
+ )
+ assert base_model == "writer.palmyra-x5-v1:0"
+
+ base_model = bedrock_model_info.get_base_model(
+ model="bedrock/us.writer.palmyra-x4-v1:0"
+ )
+ assert base_model == "writer.palmyra-x4-v1:0"