Skip to content

feat: support openai-compatible endpoints and model discovery for agents - #251

Draft
vigneshrajsb wants to merge 5 commits into
mainfrom
openai-compatible-provider-base-url
Draft

vigneshrajsb wants to merge 5 commits into
mainfrom
openai-compatible-provider-base-url

Conversation

@vigneshrajsb

@vigneshrajsb vigneshrajsb commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Add an optional baseUrl to the openai agent provider. Lifecycle sends the requests for this provider to that OpenAI-compatible endpoint, for example a self-hosted LLM gateway.
  • When baseUrl is set, Lifecycle uses the Chat Completions API. It does not use the Responses API.
  • Add an optional discoverModels flag. When it is set, the model list comes from GET {baseUrl}/models with the shared provider key. Configured models become overrides for name, default, and limits.
  • Discovered models are sorted, so the default model stays the same. Lifecycle keeps the list for five minutes and keeps the last good list when a refresh fails.
  • User keys for the provider are validated against baseUrl.
  • Add baseUrl and discoverModels to the runtime config schema and to the OpenAPI spec.

Verifying Changes

  • pnpm test, pnpm lint, and tsc pass.
  • Tested on a local server with an OpenAI-compatible gateway: model discovery, chat, and tool calls on two model families.

Notes

  • There is no change in behavior when baseUrl is not set.
  • The settings UI change is in GoodRxOSS/lifecycle-ui#86.

Lets an administrator point the openai provider at any OpenAI-compatible
endpoint, such as a self-hosted LLM gateway, by setting `baseUrl` on the
provider entry in the agent runtime config.

- When `baseUrl` is set, models are created against Chat Completions rather
  than the Responses API, since that is the interface gateways implement.
- `baseUrl` applies to every key used for the provider, including keys users
  save themselves, and saved keys are validated against it.
- The runtime config validator rejects `baseUrl` on other providers, non-http(s)
  URLs, and URLs with embedded credentials.
- `baseUrl` is declared in the runtime config JSON schema and OpenAPI spec.
Adds `discoverModels` to the openai provider. When set together with
`baseUrl`, the model list comes from `GET {baseUrl}/models` using the shared
provider key, so adding a model on the endpoint makes it selectable without a
config change.

- Configured `models` entries act as per-model overrides for display name,
  default, token limit and pricing; `enabled: false` hides a model, and entries
  the endpoint no longer lists are dropped.
- Results are cached per endpoint and key for five minutes. A failed refresh
  keeps serving the last known list; if discovery has never succeeded, the
  configured models are used.
- The validator requires `baseUrl` for discovery and no longer requires an
  enabled model on a discovering provider.
The first model is the default when no override pins one, and gateways
return /models in varying order, so the default changed between refreshes.
Discovered ids are now sorted.
- Reject a baseUrl with a query string or fragment.
- Validate saved keys against a custom endpoint only on a 2xx
  response, with a timeout.
- Treat an empty model list as a failed refresh.
- Share the discovery cache for a baseUrl with and without a
  trailing slash, and sort ids by code unit.
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