Skip to content

Add OpenAI-compatible /v1/models endpoint to OpenCode Zen for automatic model discovery #2901

Closed

Description

@danilevy1212

problem

opencode zen currently doesn't expose a /v1/models endpoint, which prevents openai-compatible clients (like openwebui) from automatically discovering available models.

this forces users to manually add each model id to their client configuration, which is:

  • time-consuming (11+ models to add manually)
  • error-prone (typos in model ids)
  • not future-proof (requires manual updates when new models are added)

proposed solution

implement a /v1/models endpoint that returns an openai-compatible response listing all available opencode zen models.

endpoint: get /v1/models

response format (openai-compatible):

{
  "object": "list",
  "data": [
    {
      "id": "claude-3-5-haiku",
      "object": "model",
      "created": 1234567890,
      "owned_by": "anthropic"
    },
    {
      "id": "claude-sonnet-4",
      "object": "model",
      "created": 1234567890,
      "owned_by": "anthropic"
    }
  ]
}

the model data is already available at https://models.dev/api.json under .opencode.models, making implementation straightforward:

# current model list (11 models)
curl https://models.dev/api.json -s | jq '.opencode.models | keys'

use cases

this would enable openwebui and other openai-compatible clients to:

  • ✅ automatically discover available opencode zen models on startup
  • ✅ dynamically refresh model lists when new models are added
  • ✅ provide better ux without manual configuration
  • ✅ reduce support burden for integration issues

current workaround

building a local proxy server that:

  1. intercepts /v1/models requests
  2. fetches from models.dev/api.json
  3. transforms to openai-compatible format
  4. forwards all other requests to opencode

however, native support in opencode would be cleaner and more maintainable.

references

Activity

  1. rekram1-node commented on Oct 1, 2025

    @rekram1-node
    Contributor

    makes sense, thanks for raising

  2. danilevy1212 commented on Nov 2, 2025

    @danilevy1212
    Author

    Looks like it works now!

    curl -s https://opencode.ai/zen/v1/models | jq
    {
      "object": "list",
      "data": [
        {
          "id": "claude-opus-4-1",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "claude-sonnet-4",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "claude-sonnet-4-5",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "claude-3-5-haiku",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "claude-haiku-4-5",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "gpt-5",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "gpt-5-codex",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "qwen3-coder",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "glm-4.6",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "big-pickle",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "an-gbt",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "kimi-k2",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "minimax-m2",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        },
        {
          "id": "grok-code",
          "object": "model",
          "created": 1762047082,
          "owned_by": "opencode"
        }
      ]
    }
  3. dhruvkej9 commented on Apr 25, 2026

    @dhruvkej9

    @rekram1-node Also can there be a config option config.json similar to this which handles the models using the v1/models? for any link?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions