Skip to content

Commit 239b00a

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 aff928c commit 239b00a

File tree

4 files changed

+635
-3
lines changed

4 files changed

+635
-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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ packages = ["src/strands"]
5050
anthropic = [
5151
"anthropic>=0.21.0,<1.0.0",
5252
]
53+
# Optional dependencies for different AI providers
54+
5355
dev = [
5456
"commitizen>=4.4.0,<5.0.0",
5557
"hatch>=1.0.0,<2.0.0",
@@ -79,12 +81,16 @@ openai = [
7981
"openai>=1.68.0,<2.0.0",
8082
]
8183

84+
portkey = [
85+
"portkey-ai>=1.0.0,<2.0.0",
86+
]
87+
8288
[tool.hatch.version]
8389
# Tells Hatch to use your version control system (git) to determine the version.
8490
source = "vcs"
8591

8692
[tool.hatch.envs.hatch-static-analysis]
87-
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai"]
93+
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai","portkey"]
8894
dependencies = [
8995
"mypy>=1.15.0,<2.0.0",
9096
"ruff>=0.11.6,<0.12.0",
@@ -107,7 +113,7 @@ lint-fix = [
107113
]
108114

109115
[tool.hatch.envs.hatch-test]
110-
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai"]
116+
features = ["anthropic", "litellm", "llamaapi", "ollama", "openai", "portkey"]
111117
extra-dependencies = [
112118
"moto>=5.1.0,<6.0.0",
113119
"pytest>=8.0.0,<9.0.0",
@@ -123,7 +129,7 @@ extra-args = [
123129

124130
[tool.hatch.envs.dev]
125131
dev-mode = true
126-
features = ["dev", "docs", "anthropic", "litellm", "llamaapi", "ollama"]
132+
features = ["dev", "docs", "anthropic", "litellm", "llamaapi", "ollama", "portkey"]
127133

128134

129135

0 commit comments

Comments
 (0)