Skip to content

Add Vercel AI Gateway as a Provider#727

Open
285729101 wants to merge 1 commit intoMerit-Systems:masterfrom
285729101:feat/vercel-ai-gateway
Open

Add Vercel AI Gateway as a Provider#727
285729101 wants to merge 1 commit intoMerit-Systems:masterfrom
285729101:feat/vercel-ai-gateway

Conversation

@285729101
Copy link

Summary

Closes #573

Adds the Vercel AI Gateway as a new provider, enabling Echo users to route requests through Vercel's unified AI gateway to access models from multiple upstream providers (OpenAI, Anthropic, Google, xAI, Mistral, DeepSeek, etc.) through a single endpoint.

Changes

SDK (packages/sdk/ts)

  • Added packages/sdk/ts/src/supported-models/chat/vercel.ts with model definitions and per-token pricing for 25 models across 6 upstream providers (Anthropic, DeepSeek, Google, Mistral, OpenAI, xAI). Pricing is sourced from the Vercel AI Gateway API via @ai-sdk/gateway.
  • Added packages/sdk/ts/src/providers/vercel.ts with createEchoVercelAIGateway() SDK provider function using @ai-sdk/gateway.
  • Added packages/sdk/ts/scripts/update-vercel-models.ts script to auto-update model definitions and pricing from the gateway API (matches the pattern used by update-openai-models.ts, update-anthropic-models.ts, etc.).
  • Moved @ai-sdk/gateway from devDependencies to dependencies since it is now used at runtime.
  • Added update-models:vercel npm script and included it in update-all-models.
  • Updated src/index.ts, src/providers/index.ts, and src/supported-models/index.ts to export the new VercelModels, VercelModel type, createEchoVercelAIGateway, and VercelAIGatewayProvider type.

Router/Server (packages/app/server)

  • Added VERCEL_AI_GATEWAY to the ProviderType enum.
  • Added VercelAIGatewayProvider server-side provider that routes requests to https://ai-gateway.vercel.sh/v1. Uses the OpenAI-compatible SSE format for streaming and non-streaming responses.
  • Updated ProviderFactory to map Vercel provider models to the new VERCEL_AI_GATEWAY provider type and instantiate VercelAIGatewayProvider.
  • Updated AccountingService to include VercelModels in the supported models list for accurate cost tracking.
  • Added VERCEL_API_KEY to env.ts for gateway authentication.

Pricing

Model pricing uses the Vercel AI Gateway pricing API (already used in packages/sdk/ts/scripts/update-models.ts). The update-vercel-models.ts script fetches live pricing and regenerates the static model definitions. Models use the @provider/model ID format (e.g., @openai/gpt-4o, @anthropic/claude-sonnet-4).

Test plan

  • Verify SDK builds successfully with pnpm build in packages/sdk/ts
  • Verify server builds successfully with pnpm build in packages/app/server
  • Verify VercelModels are exported and accessible from the SDK
  • Test createEchoVercelAIGateway() creates a valid gateway provider
  • Test routing a chat completion request with a Vercel model ID (e.g., @openai/gpt-4o)
  • Verify cost accounting correctly calculates token costs for Vercel models
  • Run pnpm update-models:vercel to confirm the update script works with the gateway API

@vercel
Copy link
Contributor

vercel bot commented Feb 18, 2026

@285729101 is attempting to deploy a commit to the Merit Systems Team on Vercel.

A member of the Team first needs to authorize it.

@285729101
Copy link
Author

@rsproule @fmhall would love your review on this when you get a chance. The gateway integration follows the same patterns as the existing providers and uses the pricing API for accurate cost tracking.

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.

Add the Vercel AI Gateway as a Provider

1 participant