Skip to content

Conversation

@kyesw
Copy link

@kyesw kyesw commented Feb 11, 2026

Summary

  • Add PortkeyModel integration that routes requests through the Portkey AI gateway, enabling observability, caching, fallbacks, and load balancing across any LLM provider
  • The gateway automatically infers the provider from model_id, so only api_key and model_id are required:
    model = PortkeyModel(api_key="pk-...", model_id="gpt-4o")
  • Extends OpenAIModel since Portkey normalizes all provider responses into the OpenAI-compatible format
  • Add portkey-ai as optional dependency (pip install strands-agents[portkey])

Files changed

File Change
src/strands/models/portkey.py New PortkeyModel implementation
src/strands/models/__init__.py Lazy loading registration
tests/strands/models/test_portkey.py 20 unit tests
pyproject.toml Optional dependency + all extra

Usage examples

from strands import Agent
from strands.models.portkey import PortkeyModel

# OpenAI
model = PortkeyModel(api_key="pk-...", model_id="gpt-4o")

# Anthropic — just change the model_id
model = PortkeyModel(api_key="pk-...", model_id="claude-sonnet-4-20250514")

# Google
model = PortkeyModel(api_key="pk-...", model_id="gemini-2.0-flash")

# With Portkey config for routing/fallbacks/load balancing
model = PortkeyModel(api_key="pk-...", config="cf-xxx", model_id="gpt-4o")

agent = Agent(model=model)
agent("Hello!")

Test plan

  • hatch fmt --formatter — passed
  • hatch fmt --linter — passed
  • hatch test -- tests/strands/models/test_portkey.py — 20/20 passed
  • Manual verification with Portkey gateway using Bedrock model

Add PortkeyModel integration that routes requests through the Portkey AI
gateway, enabling observability, caching, fallbacks, and load balancing
across any LLM provider (OpenAI, Anthropic, Google, Mistral, etc.).

The gateway automatically infers the provider from the model_id, so only
api_key and model_id are required:

    model = PortkeyModel(api_key="pk-...", model_id="gpt-4o")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant