Skip to content

Add baseten integration #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

philipkiely-baseten
Copy link

Description

Adds Baseten as a model provider

Related Issues

Documentation PR

strands-agents/docs#124

Type of Change

New feature

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@yonib05
Copy link
Member

yonib05 commented Jul 10, 2025

Hey @philipkiely-baseten,
Thank you so much for this PR and your contribution! We really appreciate the work you've put into this, and Baseten looks like a fantastic platform.
While we'd love to include every great model provider, we've reached a point where we need to be selective about adding new providers directly to the core SDK to keep it maintainable and focused.

That said, we absolutely want to support your integration! We'd recommend one of these approaches:

  • Option 1: Publish your model provider implementation as a standalone package on PyPI. This way, customers can easily install it and use it with our SDK. Here's a great example of how this works: https://pypi.org/project/strands-nvidia-nim/
  • Option 2: Include it as a submodule in your official Baseten SDK https://pypi.org/project/baseten/, which would give your users direct access through your existing package.

Either way, we'd be happy to feature you on our documentation page as a supported model provider, giving you visibility to our community.
Would either of these approaches work for your use case? We're excited to see Baseten integrated with our ecosystem!

from typing_extensions import Unpack, override

from ..types.content import Messages
from ..types.models import OpenAIModel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import path is out of date.

return cast(BasetenModel.BasetenConfig, self.config)

@override
def stream(self, request: dict[str, Any]) -> Iterable[dict[str, Any]]:
Copy link
Contributor

@JackYPCOnline JackYPCOnline Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here.

elif "base_url" in self.config:
client_args["base_url"] = self.config["base_url"]

self.client = openai.OpenAI(**client_args)
Copy link
Contributor

@JackYPCOnline JackYPCOnline Jul 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've migrated to AsyncOpenAI in our implementation. Please verify this change is properly reflected throughout the codebase in your PR. Also, ensure you've pulled the most recent code before proceeding with your review.

Returns:
An iterable of response events from the Baseten model.
"""
response = self.client.chat.completions.create(**request)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

async happens also here ^^

yield {"chunk_type": "metadata", "data": event.usage}

@override
def structured_output(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might want to update async here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants