Skip to content

Add Requesty provider#811

Open
Thibaultjaigu wants to merge 1 commit into
CodebuffAI:mainfrom
Thibaultjaigu:add-requesty-provider
Open

Add Requesty provider#811
Thibaultjaigu wants to merge 1 commit into
CodebuffAI:mainfrom
Thibaultjaigu:add-requesty-provider

Conversation

@Thibaultjaigu

Copy link
Copy Markdown

Summary

Adds an optional direct Requesty provider route to the SDK. Requesty is an OpenAI-compatible model router (https://router.requesty.ai/v1) that uses the same provider/model id form as OpenRouter (e.g. openai/gpt-4o-mini, anthropic/claude-sonnet-4.5).

When the REQUESTY_API_KEY environment variable is set, chat completions are routed directly to the Requesty router using the existing @codebuff/llm-providers OpenAICompatibleChatLanguageModel shim, instead of going through the Codebuff backend. When the env var is unset, behavior is unchanged.

This mirrors the existing direct ChatGPT OAuth route in sdk/src/impl/model-provider.ts (createOpenAIOAuthModel), which already builds an OpenAICompatibleChatLanguageModel pointed at a fixed upstream base URL with a Bearer key rather than the Codebuff backend. No new provider registry was invented — the change reuses the existing model-routing entry point (getModelForRequest).

Changes

Code:

  • common/src/constants/requesty.ts (new): REQUESTY_BASE_URL and REQUESTY_ENV_VAR constants, mirroring common/src/constants/byok.ts.
  • sdk/src/env.ts: getRequestyApiKeyFromEnv() helper, mirroring getByokOpenrouterApiKeyFromEnv().
  • sdk/src/impl/model-provider.ts: createRequestyModel() (mirrors createOpenAIOAuthModel()) and a direct-route branch at the top of getModelForRequest().

Tests:

  • sdk/src/impl/__tests__/model-provider-requesty.test.ts (new): asserts the route is selected when REQUESTY_API_KEY is set (provider === 'requesty') and that the default Codebuff backend route is used when it is unset.

Docs:

  • sdk/README.md: new "Model providers" section documenting the Requesty route.
  • docs/agents-and-tools.md: matching "Model providers" section.

Verification

Typecheck (no repo-wide script; ran the affected projects):

  • sdk: tsc --noEmit -p tsconfig.json → exit 0
  • packages/llm-providers: bun run typecheck → exit 0

Tests (bun test):

  • model-provider-requesty.test.ts (2) and model-provider-free-mode.test.ts (4) → 6 pass / 0 fail.

Live test against the Requesty router:

  • GET https://router.requesty.ai/v1/models → HTTP 200
  • POST https://router.requesty.ai/v1/chat/completions with openai/gpt-4o-mini → real completion returned (model gpt-4o-mini-2024-07-18).

Notes

I work at Requesty. This mirrors the existing OpenRouter provider as closely as possible. Happy to adjust or close it if it is not a fit.

Add an optional direct Requesty provider route to the SDK, mirroring the
existing direct ChatGPT OAuth route in sdk/src/impl/model-provider.ts.

When REQUESTY_API_KEY is set, chat completions are routed directly to the
Requesty OpenAI-compatible router (https://router.requesty.ai/v1) using the
existing @codebuff/llm-providers OpenAICompatibleChatLanguageModel shim,
instead of going through the Codebuff backend. Model ids use the same
provider/model form (e.g. openai/gpt-4o-mini). When the env var is unset,
behavior is unchanged.

- common/src/constants/requesty.ts: base URL + env var name (mirrors byok.ts)
- sdk/src/env.ts: getRequestyApiKeyFromEnv helper
- sdk/src/impl/model-provider.ts: createRequestyModel + wiring in getModelForRequest
- sdk/src/impl/__tests__/model-provider-requesty.test.ts: route selection tests
- docs/agents-and-tools.md, sdk/README.md: provider docs
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.

1 participant