SesameSesame

OpenCode

Multi-provider AI agent with OAuth subscription support

OpenCode is a flexible AI coding agent that supports 85+ providers from models.dev. Unlike other agents that are locked to a single provider, OpenCode lets you connect multiple AI providers and switch between models freely.

Key Features

  • 85+ Providers: Access models from Anthropic, OpenAI, Google, Mistral, Groq, and many more
  • OAuth Support: Use your Claude Pro/Max or ChatGPT Plus/Pro subscription instead of API keys
  • Multi-Provider: Connect multiple providers and switch models per-task
  • Dynamic Models: Model list updates automatically from models.dev

Getting Started

1. Open Provider Management

  1. When creating a task, select OpenCode as the agent
  2. Click Manage Providers next to the model dropdown
  3. You'll see a list of all available providers

2. Connect a Provider

For each provider, you can authenticate with either:

  • Subscription (OAuth): Use your existing Claude Pro/Max or ChatGPT Plus/Pro subscription
  • API Key: Traditional pay-per-token authentication
  1. Click Connect on Anthropic or OpenAI
  2. Select Use Subscription (default when OAuth is available)
  3. Click Sign in with [Provider]
  4. Complete the authentication flow:
    • Anthropic: Visit the URL, copy the code, paste it back
    • OpenAI: Visit the URL, enter the device code shown
  5. Once authenticated, you're connected!

Using API Key

  1. Click Connect on any provider
  2. Select Use API Key
  3. Enter your API key
  4. Click Connect

3. Select a Model

After connecting at least one provider, you can select models from the dropdown:

  • Models are grouped by provider
  • Only models from connected providers are shown
  • The list updates dynamically from models.dev

OAuth Authentication

Claude Pro/Max (Anthropic)

Supported subscriptions: Claude Max ($200/mo), Claude Pro ($20/mo)

The OAuth flow for Anthropic uses a "code" method:

  1. Click Sign in with anthropic
  2. A browser window opens to Anthropic's authorization page
  3. Log in and authorize the application
  4. Copy the authorization code shown
  5. Paste it back in Sesame
  6. Click Submit Code

ChatGPT Plus/Pro (OpenAI)

Supported subscriptions: ChatGPT Plus ($20/mo), ChatGPT Pro ($200/mo)

The OAuth flow for OpenAI uses a "device code" method:

  1. Click Sign in with openai
  2. You'll see a URL and a device code (e.g., ABCD-1234)
  3. Visit the URL in your browser
  4. Enter the device code when prompted
  5. Authorize the application
  6. Sesame automatically detects completion and connects

OAuth tokens are stored encrypted and may expire. If authentication fails, disconnect and reconnect the provider.

Provider Management

Viewing Connected Providers

The provider dialog shows:

  • Connected section: Providers you've authenticated
  • Available section: Providers you can connect
  • Each provider shows the number of available models

Disconnecting a Provider

  1. Open Manage Providers
  2. Find the connected provider
  3. Click the trash icon to disconnect
  4. Both API key and OAuth credentials are removed

Multiple Providers

You can connect multiple providers simultaneously:

  • Use Anthropic for Claude models
  • Use OpenAI for GPT models
  • Use Groq for fast inference
  • Switch between them per-task via the model dropdown

Advanced: JSON Configuration (Legacy)

For advanced users, OpenCode also supports raw JSON configuration. This is useful for:

  • Custom model parameters
  • Provider-specific settings
  • MCP server configuration

JSON configuration is a legacy feature. For most users, the provider management UI is simpler and recommended.

Using JSON Config

  1. In the Agent Credentials dialog, select OpenCode
  2. Toggle to JSON Configuration mode
  3. Enter your configuration:
{
  "$schema": "https://opencode.ai/config.json",
  "model": "anthropic/claude-sonnet-4-5",
  "provider": {
    "anthropic": {
      "apiKey": "{env:ANTHROPIC_API_KEY}"
    }
  }
}

Environment Variable Substitution

Use {env:VAR_NAME} to reference API keys stored in Settings:

{
  "provider": {
    "anthropic": {
      "apiKey": "{env:ANTHROPIC_API_KEY}"
    },
    "openai": {
      "apiKey": "{env:OPENAI_API_KEY}"
    }
  }
}

MCP Server Integration

OpenCode supports Model Context Protocol (MCP) servers. Any MCP servers configured in Sesame are automatically available to OpenCode tasks.

You can also add MCP servers in JSON config:

{
  "mcp": {
    "filesystem": {
      "type": "local",
      "command": ["npx", "-y", "@modelcontextprotocol/server-filesystem", "/workspace"],
      "enabled": true
    }
  }
}

Troubleshooting

"No providers configured"

Connect at least one provider via Manage Providers before running a task.

OAuth Flow Fails

  1. Check your subscription is active
  2. Ensure you're logged into the correct account
  3. For Anthropic: make sure you copy the full authorization code
  4. For OpenAI: wait for the device code flow to complete automatically

Token Expired

OAuth tokens may expire over time. Disconnect and reconnect the provider to refresh.

Model Not Available

  • Verify the provider is connected (check for green checkmark)
  • Some models require specific subscription tiers
  • Model availability updates from models.dev; try refreshing

"OpenCode CLI not found"

The sandbox must have OpenCode installed. Check your sandbox configuration includes the OpenCode CLI.

Reference

On this page