Repository navigation
Description
Feature hasn't been suggested before.
- I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
I am a newbie using opencode, so maybe this is already covered somewhere and I failed to spot it. I am sorry about that if this is the case.
I was trying to use mistral models through vertexai in opencode and it fail. The reason is that mistral seems to expect openai compatible communication. The following was generated by AI:
Feature Request: Native Support for Mistral Models on Google Vertex AI
Summary
Add native support for Mistral AI models (e.g., mistral-small-2503, mistral-medium-3) available through Google Cloud Vertex AI in the @ai-sdk/google-vertex provider or as a separate provider package.
Problem Statement
Currently, OpenCode cannot use Mistral models deployed on Google Cloud Vertex AI because:
-
Different API Endpoint: Mistral models on Vertex AI use a different endpoint structure than standard Vertex AI models:
POST /v1/projects/{project}/locations/{location}/publishers/mistralai/models/{model}:streamRawPredictInstead of the standard generative AI endpoints.
-
Custom Request Format: Mistral models expect the native Mistral/OpenAI-compatible format (with
messages,model,stream, etc.), not the Vertex AI Gemini format. -
Plugin System Limitation: While OpenCode supports custom plugins that implement
LanguageModelV1, the framework appears to bypass customdoStream()/doGenerate()methods and instead attempts to construct HTTP requests usingbaseURL + "/chat/completions", which doesn't exist for Vertex AI endpoints.
Current Workaround
To use Mistral models on Vertex AI with OpenCode, we need to run a local proxy server that:
- Exposes an OpenAI-compatible endpoint (
/v1/chat/completions) - Translates requests to Vertex AI's
streamRawPredictformat - Converts responses back to OpenAI format
This works but requires:
- Running an additional service (proxy server)
- Manual startup before each OpenCode session
- Extra maintenance overhead
Proposed Solution
Option 1: Extend @ai-sdk/google-vertex Provider (Recommended)
Add support for Mistral models directly in the existing Google Vertex AI provider:
// Example usage
import { vertex } from '@ai-sdk/google-vertex';
const model = vertex('mistral-small-2503', {
project: 'my-project',
location: 'europe-west4',
publisher: 'mistralai', // New option
});Implementation approach:
- Detect publisher prefix (e.g.,
mistralai/*) or add explicitpublisheroption - Route to appropriate endpoint based on publisher:
- Standard Gemini models →
/generateContent - Mistral models →
/publishers/mistralai/models/{model}:streamRawPredict
- Standard Gemini models →
- Format request body according to model type:
- Gemini → Vertex AI format
- Mistral → OpenAI-compatible format
Option 2: Create Separate @ai-sdk/vertex-mistral Provider
Create a dedicated provider package for Mistral models on Vertex AI:
import { vertexMistral } from '@ai-sdk/vertex-mistral';
const model = vertexMistral('mistral-small-2503', {
project: 'my-project',
location: 'europe-west4',
});Option 3: Fix Custom Plugin Support
Ensure OpenCode/AI SDK properly respects custom doStream() and doGenerate() implementations in plugins without attempting to construct HTTP requests directly.
Current behavior:
- Custom plugin implements
LanguageModelV1withdoStream()anddoGenerate() - Framework ignores custom methods and tries to call
baseURL + "/chat/completions" - Results in
"undefined/chat/completions" cannot be parsed as a URLerror
Expected behavior:
- Framework should call the plugin's
doStream()/doGenerate()methods directly - Only fall back to HTTP client if methods are not implemented
Benefits
- Better User Experience: No need to run separate proxy services
- Enterprise Use Case: Many organizations use Google Cloud and want to leverage Mistral models through their existing Vertex AI infrastructure
- Cost Optimization: Vertex AI provides committed use discounts and simplified billing
- Compliance: Some organizations require all AI APIs to go through approved cloud platforms
- Consistency: Use the same authentication (ADC) and configuration as other Vertex AI models
Technical Details
Endpoint Format
POST https://{location}-aiplatform.googleapis.com/v1/projects/{project}/locations/{location}/publishers/mistralai/models/{model}:streamRawPredict
Request Format
{
"model": "mistral-small-2503",
"messages": [
{"role": "user", "content": "Hello"}
],
"stream": true,
"temperature": 0.7,
"max_tokens": 1024,
"tools": [...] // Optional
}Response Format
Server-Sent Events (SSE) with OpenAI-compatible streaming format:
data: {"id":"...","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"}}]}
data: [DONE]
Authentication
Uses Google Cloud Application Default Credentials (ADC), same as standard Vertex AI models.
Available Models on Vertex AI
As of 2025, Mistral AI models available on Google Cloud Vertex AI include:
mistral-small-2503(Mistral Small 3.1)mistral-medium-3(Mistral Medium 3)- Additional models as announced by Mistral AI and Google Cloud
Related Issues
This feature request is related to:
- Supporting third-party models on cloud platforms
- Improving custom plugin flexibility in OpenCode/AI SDK
- Vertex AI MaaS (Model-as-a-Service) integration
Activity
mantielero commentedon Sep 18, 2026
Find attached the proxy that I am using and that is working with
mistral-small-2503my_proxy.js
rekram1-node commentedon Oct 9, 2026
Will be in the next opencode v2 release, which should be tmr (v2.0.27):
https://opencode.ai/v2/docs
mantielero commentedon Oct 13, 2026
Do I need to set anything in particular in the configuration in order to use it?
I tried to use it today and it failed. It says that the model was not found on my project.
I am using
opencode v2.0.27.I checked with python that I can access
:rawPredictand:streamRawPredict.In my configuration file I just set:
opencode-agent commentedon Oct 13, 2026
Thanks for testing it! It depends on how the provider is set up.
Built-in
google-vertexprovider (recommended). This should just work. The built-in provider already includesmistral-small-2503,mistral-medium-3andcodestral-2and sends them to Vertex'sstreamRawPredictendpoint, so you don't neednpmor amodelsentry. Just set a project and a regional location (Mistral isn't served from theglobalendpoint):{ "provider": { "google-vertex": { "options": { "project": "your-project", "location": "europe-west4" } } } }Then pick
google-vertex/mistral-small-2503.Custom provider. If you use your own provider ID with
"npm": "@ai-sdk/google-vertex"(which is what your snippet looks like), every model goes through the Gemini route. That's why Vertex says the model isn't found in your project. For a fully custom provider, we recommend this config, which points the Mistral model at the Vertex Mistral route explicitly:{ "providers": { "my-vertex": { "package": "@opencode/ai/providers/google-vertex", "settings": { "project": "your-project", "location": "europe-west4" }, "models": { "mistral-small-2503": { "name": "Mistral Small", "package": "@opencode/ai/providers/google-vertex/mistral" } } } } }Auth uses your Application Default Credentials, the same as other Vertex models. Let us know if either one still fails, and include the exact error.
mantielero commentedon Oct 14, 2026
That worked. Thank you.