[PR #3427] Fetch from model list from /v1/models/ from OpenAI Compatible APIs #10641

Closed
opened 2026-02-16 18:15:21 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/3427

State: closed
Merged: No


This commit introduces automatic model discovery for OpenAI-compatible providers, allowing OpenCode to dynamically fetch available models from the /v1/models endpoint instead of requiring manual model configuration.

Key changes:

  • Implement automatic fetching of models from /v1/models endpoint for custom OpenAI-compatible providers
  • Add proper API key handling from both auth.json and environment variables
  • Enable support for providers using the @ai-sdk/openai-compatible npm package
  • Include enhanced logging for debugging provider configuration
  • Ensure compatibility with existing provider configuration system

This enhancement enables OpenCode to work seamlessly with OpenAI-compatible APIs such as local LLM servers (Ollama, LocalAI), API proxies, and custom implementations without requiring manual model definitions in the configuration. The functionality addresses the need for supporting custom and local AI providers with dynamic model discovery.

Fixes the issue where OpenAI-compatible providers would show no available models unless manually configured in opencode.json.

(the PR is generated by qwen, though I have tested it out locally properly with the provider, used nano-gpt.com/api/v1 for this)

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/3427 **State:** closed **Merged:** No --- This commit introduces automatic model discovery for OpenAI-compatible providers, allowing OpenCode to dynamically fetch available models from the /v1/models endpoint instead of requiring manual model configuration. Key changes: - Implement automatic fetching of models from /v1/models endpoint for custom OpenAI-compatible providers - Add proper API key handling from both auth.json and environment variables - Enable support for providers using the @ai-sdk/openai-compatible npm package - Include enhanced logging for debugging provider configuration - Ensure compatibility with existing provider configuration system This enhancement enables OpenCode to work seamlessly with OpenAI-compatible APIs such as local LLM servers (Ollama, LocalAI), API proxies, and custom implementations without requiring manual model definitions in the configuration. The functionality addresses the need for supporting custom and local AI providers with dynamic model discovery. Fixes the issue where OpenAI-compatible providers would show no available models unless manually configured in opencode.json. (the PR is generated by qwen, though I have tested it out locally properly with the provider, used nano-gpt.com/api/v1 for this)
yindo added the pull-request label 2026-02-16 18:15:21 -05:00
yindo closed this issue 2026-02-16 18:15:21 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10641