Problem
When using the OpenCode HTTP API programmatically (e.g., for sub-agent orchestration), there's no way to specify which AI provider or model to use per session or message. All sessions use the server's configured default model.
Use Case
Building a parent-agent system that spawns multiple sub-agents via the OpenCode HTTP API:
- Cost optimization: Use cheaper models (e.g., Haiku) for simple tasks like linting
- Performance: Use fast models for quick queries, powerful models for complex analysis
- Testing: Verify behavior across different providers/models
- Parallel workflows: Run different sub-agents with different models simultaneously
Current Behavior
# Creating a session - no way to specify model
POST /session?directory=...
{"title": "My Task"}
# Sending a message - model selection ignored
POST /session/:id/message?directory=...
{"parts": [...], "providerID": "anthropic", "modelID": "claude-haiku-4-5"}
# ^ These fields are ignored, uses default model
Result: Always uses server default (e.g., claude-sonnet-4-5-20250929)
Desired Behavior
Allow provider/model selection via API:
Option 1: Set at session creation
POST /session?directory=...
{
"title": "Fast Task",
"providerID": "anthropic",
"modelID": "claude-haiku-4-5"
}
Option 2: Set per message
POST /session/:id/message?directory=...
{
"parts": [{"type": "text", "text": "..."}],
"providerID": "anthropic",
"modelID": "claude-haiku-4-5"
}
Option 3: Both (most flexible)
Set default at session creation, override per message if needed.
Current Workaround
None - must accept whatever default model the server is configured with.
Additional Context
The /config/providers endpoint already exposes all available providers and models, so clients can discover what's available. We just need a way to actually select them.
API currently tested:
- ✅
/config/providers - shows all models
- ❌ Session creation with
providerID/modelID - ignored
- ❌ Message with
providerID/modelID - ignored
- ❌
/session/:id/init endpoint - only for AGENTS.md generation
This would be especially valuable for programmatic workflows where different tasks have different model requirements.
Problem
When using the OpenCode HTTP API programmatically (e.g., for sub-agent orchestration), there's no way to specify which AI provider or model to use per session or message. All sessions use the server's configured default model.
Use Case
Building a parent-agent system that spawns multiple sub-agents via the OpenCode HTTP API:
Current Behavior
Result: Always uses server default (e.g.,
claude-sonnet-4-5-20250929)Desired Behavior
Allow provider/model selection via API:
Option 1: Set at session creation
Option 2: Set per message
Option 3: Both (most flexible)
Set default at session creation, override per message if needed.
Current Workaround
None - must accept whatever default model the server is configured with.
Additional Context
The
/config/providersendpoint already exposes all available providers and models, so clients can discover what's available. We just need a way to actually select them.API currently tested:
/config/providers- shows all modelsproviderID/modelID- ignoredproviderID/modelID- ignored/session/:id/initendpoint - only for AGENTS.md generationThis would be especially valuable for programmatic workflows where different tasks have different model requirements.