Skip to content

Commit 7b0b1ee

Browse files
committed
feat: Adding portkey.ai gateway as a custom model
feat: Adding portkey.ai gateway as a custom model feat: Adding portkey.ai gateway as a custom model
1 parent e12bc2f commit 7b0b1ee

File tree

4 files changed

+638
-3
lines changed

4 files changed

+638
-3
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ from strands import Agent
118118
from strands.models import BedrockModel
119119
from strands.models.ollama import OllamaModel
120120
from strands.models.llamaapi import LlamaAPIModel
121+
from strands.models.portkey import PortkeyModel
121122

122123
# Bedrock
123124
bedrock_model = BedrockModel(
@@ -142,6 +143,17 @@ llama_model = LlamaAPIModel(
142143
)
143144
agent = Agent(model=llama_model)
144145
response = agent("Tell me about Agentic AI")
146+
147+
# Portkey for all models
148+
portkey_model = PortkeyModel(
149+
api_key="<PORTKEY_API_KEY>",
150+
model_id="anthropic.claude-3-5-sonnet-20241022-v2:0",
151+
virtual_key="<BEDROCK_VIRTUAL_KEY>",
152+
provider="bedrock",
153+
base_url="http://portkey-service-gateway.service.prod.example.com/v1",
154+
)
155+
agent = Agent(model=portkey_model)
156+
response = agent("Tell me about Agentic AI")
145157
```
146158

147159
Built-in providers:

pyproject.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ packages = ["src/strands"]
4949
anthropic = [
5050
"anthropic>=0.21.0,<1.0.0",
5151
]
52+
# Optional dependencies for different AI providers
53+
5254
dev = [
5355
"commitizen>=4.4.0,<5.0.0",
5456
"hatch>=1.0.0,<2.0.0",
@@ -88,12 +90,17 @@ a2a = [
8890
"starlette>=0.46.2",
8991
]
9092

93+
portkey = [
94+
"portkey-ai>=1.0.0,<2.0.0",
95+
]
96+
9197
[tool.hatch.version]
9298
# Tells Hatch to use your version control system (git) to determine the version.
9399
source = "vcs"
94100

95101
[tool.hatch.envs.hatch-static-analysis]
96-
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai", "otel"]
102+
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai", "otel", "portkey"]
103+
97104
dependencies = [
98105
"mypy>=1.15.0,<2.0.0",
99106
"ruff>=0.11.6,<0.12.0",
@@ -116,7 +123,8 @@ lint-fix = [
116123
]
117124

118125
[tool.hatch.envs.hatch-test]
119-
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai", "otel"]
126+
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai", "otel", "portkey"]
127+
120128
extra-dependencies = [
121129
"moto>=5.1.0,<6.0.0",
122130
"pytest>=8.0.0,<9.0.0",
@@ -132,7 +140,8 @@ extra-args = [
132140

133141
[tool.hatch.envs.dev]
134142
dev-mode = true
135-
features = ["dev", "docs", "anthropic", "litellm", "llamaapi", "ollama", "otel"]
143+
144+
features = ["dev", "docs", "anthropic", "litellm", "llamaapi", "ollama", "otel", "portkey"]
136145

137146
[tool.hatch.envs.a2a]
138147
dev-mode = true

0 commit comments

Comments
 (0)