Skip to content

Unified Models list API (Anthropic format) + dynamic model forwarding #2

@krrish-berri-2

Description

@krrish-berri-2

Intended for the LAP platform repo (litellm-agent-platform-2), but issues are disabled there — filing here since this server is the concrete case.

Context

Runtime agents take a model (forwarded by LAP on the agent). There's no way for LAP/users to discover which models a runtime supports, and this server rejects unknown models.

Observed (PR #81 / this server):

  • Registers a fixed model list via LITELLM_MODELS env, passed to opencode's provider config.
  • opencode rejects any model not in that map → session fails with session.error. Reproduced: litellm/claude-sonnet-4-5 works; litellm/gpt-5.5 errors until added to the env list.
  • LAP forwards the agent's model; a bare name (claude-sonnet-4-5) doesn't match the server's litellm/<model> assumption → opencode can't resolve it.

Operator has to hand-maintain a per-runtime model env list; a mismatch silently errors the session.

Ask

1. Unified Models list API in the SDK — one method listing a runtime's models in the Anthropic Models list format (Models.list{ "data": [{ "id", "type":"model", "display_name", "created_at" }] }), normalized across runtimes:

  • anthropic (claude managed agents) → Anthropic GET /v1/models
  • cursor → map Cursor's list into the Anthropic shape
  • opencode-behind-Anthropic → proxy the gateway's /v1/models (e.g. LiteLLM) into the Anthropic shape

LAP reads this to populate the model picker so users pick a valid model.
Ref: https://platform.claude.com/docs/en/api/python/models/list

2. Dynamic model forwarding (server side) — accept whatever model is sent and forward it, no pre-registered env list. When a gateway is configured: normalize the agent model to litellm/<id> and register it dynamically in opencode's provider map at agent-create time, so any picked model works without redeploying with a new LITELLM_MODELS.

Acceptance

  • SDK: models().list(runtime) returns Anthropic-format list for anthropic / cursor / opencode-anthropic.
  • This server: GET /v1/models proxying the gateway list; agent model accepted + dynamically registered + routed (no LITELLM_MODELS requirement).
  • A session using any listed model no longer errors with session.error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions