To pick a specific provider and model via OpenRouter using Forge code, you can specify the model slug and prioritize providers with the provider field in your request. Use the order array to list provider slugs in priority order, and set allow_fallbacks to false if you want to restrict to only those providers.
Example JSON body for your request:
{
"model": "provider/model-name",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"provider": {
"order": ["provider1", "provider2"],
"allow_fallbacks": false
}
}
Replace "provider/model-name" with your desired model slug, and "provider1", "provider2" with the exact provider slugs you want to use (including variants like /turbo if needed).
You can get exact provider slugs from the model pages on OpenRouter.
Here is a TypeScript-style fetch example:
fetch('https://openrouter.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer <OPENROUTER_API_KEY>',
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'mistralai/mixtral-8x7b-instruct',
messages: [{ role: 'user', content: 'Hello' }],
provider: {
order: ['openai', 'together'],
allow_fallbacks: false
}
}),
});
This ensures your request uses the specified provider and model with your OpenRouter credits.
Would you like guidance on how to identify your website platform to help with JavaScript snippet installation next?
-# This is an automated response. Use !mute to stop the bot from responding.