Skip to content
    ↑↓ select↵ openesc close
    English中文
    hugefiver

    Provider

    v0.3.14Model Providers
    @oai2lmapi/opencode-provider

    AI SDK Provider and OpenCode Plugin for OpenAI-compatible APIs with automatic model discovery

    GitHub stars

    11

    Monthly installs

    419

    79 in 7 days

    Composite scoreSCORE

    44.9

    Multi-signal model

    Last commit

    3 days ago

    2026-08-16

    Install and configure

    opencode.json

    Writes to this project's opencode.json — applies to this repository only.

    opencode.json

    {
      "$schema": "https://opencode.ai/config.json",
      "plugin": ["@oai2lmapi/opencode-provider@0.3.14"]
    }

    opencode loads npm dependencies through its embedded runtime on startup and caches them locally — no manual global install needed.

    Build Status Version Installs Rating VS Code Marketplace License

    A VSCode extension that connects OpenAI-compatible APIs to VSCode's Language Model API, enabling integration with GitHub Copilot Chat and other AI-powered features in VSCode.

    Features

    • Full OpenAI API Compatibility: Works with any OpenAI-compatible API endpoint
    • Google Gemini Support: Native support for Google Gemini API with dedicated channel
    • VSCode Language Model API Integration: Seamlessly integrates with VSCode's built-in language model features
    • Streaming Support: Real-time streaming responses for better user experience
    • Thinking/Reasoning Support: Stream reasoning content from models that support it (e.g., o1, Claude with thinking)
    • Automatic Model Loading: Fetches available models from the API endpoint on startup
    • Model Caching: Loaded models are cached locally for faster startup times
    • Dynamic Model Metadata: Fetches up-to-date token limits and capabilities from models.dev with a 7-day local cache for offline use
    • Secure API Key Storage: API keys are stored securely using VSCode's SecretStorage
    • Tool Calling Support: Full support for tool/function calling with improved reliability
    • XML-based Tool Calling: Fallback prompt-based tool calling for models without native support
    • Tool Calling Filter: Optionally filter models by tool/function calling support
    • Per-Model Configuration: Customize token limits, temperature, and capabilities per model
    • Easy Configuration: Simple setup through VSCode settings and commands

    Requirements

    • VSCode version 1.107.0 or higher
    • An OpenAI-compatible API endpoint
    • API key for authentication

    Installation

    From VS Code Marketplace (Recommended)

    1. Open VSCode
    2. Go to Extensions view (Ctrl+Shift+X / Cmd+Shift+X)
    3. Search for "OAI2LMApi"
    4. Click Install

    Or install directly via VS Code Marketplace.

    From VSIX

    1. Download the .vsix file from the Releases page
    2. In VSCode, open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
    3. Run "Extensions: Install from VSIX..." and select the downloaded file

    From Source

    1. Clone this repository
    2. Run pnpm install to install dependencies
    3. Run pnpm run compile to build the extension
    4. Press F5 in VSCode to run the extension in debug mode
    5. To create a VSIX, run pnpm run package — the file will be generated in the root directory (e.g., oai2lmapi-0.3.4.vsix).

    Quick Start

    1. Install the extension
    2. Open Command Palette (Ctrl+Shift+P / Cmd+Shift+P)
    3. Run OAI2LMApi: Set API Key and enter your API key
    4. (Optional) Configure the API endpoint in settings if not using OpenAI
    5. Models will be automatically loaded and available in GitHub Copilot Chat

    Commands

    Command Description
    OAI2LMApi: Set API Key Securely store your OpenAI-compatible API key
    OAI2LMApi: Clear API Key Remove the stored OpenAI-compatible API key
    OAI2LMApi: Set Gemini API Key Securely store your Google Gemini API key
    OAI2LMApi: Clear Gemini API Key Remove the stored Gemini API key
    OAI2LMApi: Set Claude API Key Securely store your Claude API key
    OAI2LMApi: Clear Claude API Key Remove the stored Claude API key
    OAI2LMApi: Refresh Models Manually reload available models from all providers and force-refresh the models.dev metadata cache
    OAI2LMApi: Manage Provider Settings Open extension settings
    OAI2LMApi: Manage Claude Provider Settings Open Claude channel settings

    Configuration

    Configure the extension through VSCode settings (Ctrl+, or Cmd+,):

    Basic Settings

    Setting Default Description
    oai2lmapi.apiEndpoint https://api.openai.com/v1 OpenAI-compatible API endpoint URL
    oai2lmapi.autoLoadModels true Automatically load models from API on startup
    oai2lmapi.showModelsWithoutToolCalling false Show models that do not support tool/function calling
    oai2lmapi.openaiResponsesApiMode off When to use the OpenAI Responses API: off, gpt-only (GPT models only), or all
    oai2lmapi.suppressChainOfThought false Strip <think>...</think> blocks and suppress reasoning_content/thinking fields from responses
    oai2lmapi.trimXmlToolParameterWhitespace false Trim leading/trailing whitespace from XML-based tool call parameter values

    Gemini Settings

    Setting Default Description
    oai2lmapi.enableGeminiChannel false Enable the Gemini channel provider
    oai2lmapi.geminiApiEndpoint https://generativelanguage.googleapis.com Google Gemini API endpoint URL

    Claude Settings

    Setting Default Description
    oai2lmapi.enableClaudeChannel false Enable the Claude channel provider
    oai2lmapi.claudeApiEndpoint "" (empty) Anthropic Claude API endpoint URL. If empty and the OpenAI endpoint is set to a custom OpenAI-compatible API, that endpoint is used for Claude requests. Defaults to https://api.anthropic.com/v1 at runtime when left empty.

    Model Overrides

    The oai2lmapi.modelOverrides setting allows per-model configuration. Keys are model name patterns (supports wildcards like gemini-*), values are configuration objects.

    The oai2lmapi.channelModelOverrides setting allows per-channel configuration. Keys are channel names (e.g. openai, gemini, claude) and values are objects mapping model patterns to override objects. Matching overrides are merged in order: global modelOverrides then channel overrides.

    Property Type Description
    maxInputTokens number Override max input tokens
    maxOutputTokens number Override max output tokens
    supportsToolCalling boolean Override tool calling support
    supportsImageInput boolean Override image input support
    temperature number Default temperature for the model
    thinkingLevel string/number Thinking level: token budget number, or 'low'/'medium'/'high'/'auto'/'none'
    usePromptBasedToolCalling boolean Use XML-based prompt tool calling instead of native function calling
    useResponsesApi boolean Force-enable or disable OpenAI Responses API for matching models (overrides openaiResponsesApiMode)
    suppressChainOfThought boolean Override oai2lmapi.suppressChainOfThought for matching models
    trimXmlToolParameterWhitespace boolean Override oai2lmapi.trimXmlToolParameterWhitespace for matching models

    Example Configuration

    {
      "oai2lmapi.apiEndpoint": "https://api.openai.com/v1",
      "oai2lmapi.autoLoadModels": true,
      "oai2lmapi.showModelsWithoutToolCalling": false,
      "oai2lmapi.enableGeminiChannel": true,
      "oai2lmapi.geminiApiEndpoint": "https://generativelanguage.googleapis.com",
      "oai2lmapi.enableClaudeChannel": true,
      "oai2lmapi.claudeApiEndpoint": "https://api.anthropic.com/v1",
      "oai2lmapi.modelOverrides": {
        "gemini-2.0-flash-thinking-exp": {
          "thinkingLevel": "auto",
          "usePromptBasedToolCalling": true
        },
        "claude-*": {
          "maxOutputTokens": 8192
        }
      },
      "oai2lmapi.channelModelOverrides": {
        "openai": {
          "gpt-4o": {
            "temperature": 0.7
          }
        },
        "claude": {
          "claude-3.7*": {
            "thinkingLevel": "high"
          }
        }
      }
    }
    

    API Key Storage

    The API key is stored securely using VSCode's built-in SecretStorage. Use the OAI2LMApi: Set API Key command to set your key.

    Note: If you previously stored an API key in settings (the deprecated oai2lmapi.apiKey setting), it will be automatically migrated to secure storage.

    Supported APIs

    This extension works with any API that implements the OpenAI chat completions format:

    • OpenAI API
    • Azure OpenAI
    • Google Gemini API (native support via Gemini channel)
    • Anthropic Claude (native Claude channel via @anthropic-ai/sdk)
    • LocalAI
    • Ollama (with OpenAI compatibility layer)
    • LM Studio
    • vLLM
    • liteLM (transfer from other APIs)
    • OpenRouter
    • Any custom OpenAI-compatible implementation

    Troubleshooting

    Extension doesn't activate

    • Ensure you're using VSCode 1.107.0 or higher
    • Verify the extension is enabled in the Extensions view

    Models not loading

    • Run OAI2LMApi: Set API Key to ensure your API key is configured
    • For Gemini: Enable oai2lmapi.enableGeminiChannel and run OAI2LMApi: Set Gemini API Key
    • For Claude: Enable oai2lmapi.enableClaudeChannel and run OAI2LMApi: Set Claude API Key
    • Verify your API endpoint is correct and accessible
    • Check the OAI2LMApi Output Channel (View > Output, select "OAI2LMApi") for detailed logs
    • Try OAI2LMApi: Refresh Models to manually reload

    API errors

    • Ensure your API endpoint supports /v1/models and /v1/chat/completions
    • For Gemini: The extension uses the native Gemini API format, not OpenAI compatibility
    • Verify network connectivity to the API endpoint

    Tool calling issues

    • Some models don't support native function calling
    • Use usePromptBasedToolCalling: true in model overrides for XML-based fallback
    • Check model capabilities in the Output Channel logs

    Development Notes

    • Model metadata patterns are maintained in @oai2lmapi/model-metadata (packages/model-metadata/src/index.ts) and shared across the project.

    License

    Anti American AI Public License - See LICENSE for details.

    Contributing

    Contributions are welcome! Please feel free to submit issues or pull requests on GitHub.