-
Notifications
You must be signed in to change notification settings - Fork 237
feat(ai-gateway-provider): add embedding model support #374
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
base: main
Are you sure you want to change the base?
Conversation
Add AiGatewayEmbeddingModel class that wraps underlying embedding models and routes requests through AI Gateway, similar to the chat model. - Create new AiGatewayEmbeddingModel implementing EmbeddingModelV3 - Add embedding(), textEmbedding(), and textEmbeddingModel() methods to AiGateway interface - Extract shared types, errors, and utilities to shared.ts to avoid circular imports - Add comprehensive test coverage for embedding functionality - Support all gateway options (caching, logging, retries, metadata) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🦋 Changeset detectedLatest commit: 7c03126 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Add tests for AiGatewayDoesNotExist (400/2001) and AiGatewayUnauthorizedError (401/2009) error cases to match the chat model test coverage. Co-Authored-By: Claude Opus 4.5 <[email protected]>
The EmbeddingModelV3Result requires a `warnings` array (not optional). Explicitly construct the return object to ensure V3 compliance regardless of what the underlying model returns. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Testing NotesI tested this implementation locally by routing Google embedding requests through AI Gateway. The routing works correctly - requests are intercepted, reformatted for the Universal Endpoint, and return successful responses. Debug logs from local testing (not included in final code): Note: Embedding requests don't appear in the AI Gateway dashboard, though they route correctly and return 200 responses. This may require backend support to display embedding analytics alongside chat completions. |
|
@threepointone Hey! Not sure who the right person to tag is, but I'd love to get your thoughts on this. |
|
@palashgo what do you think |
Summary
Adds embedding model support to ai-gateway-provider, allowing users to route embedding requests through AI Gateway.
Changes
AiGatewayEmbeddingModelclass implementingEmbeddingModelV3embedding(),textEmbedding(), andtextEmbeddingModel()methods to the provider factoryshared.tsto avoid circular importsUsage
Test plan
🤖 Generated with Claude Code