Skip to content

Models

Model configuration, provider setup, custom endpoints.

Set ANTHROPIC_API_KEY to start. Use /model to switch mid-session. Use /login for OAuth providers. Add models.json for Ollama, LM Studio, or any OpenAI-compatible server. Soma works with any provider the engine supports — you’re not locked to Anthropic.

Quick Start

Soma needs at least one AI provider configured. The fastest path:

export ANTHROPIC_API_KEY=sk-ant-...
soma

That’s it. Soma will use Claude as the default model.

Supported Providers

Soma runs on the Pi engine, which supports 17+ providers out of the box:

Subscription-Based (OAuth)

Use /login inside a session to authenticate:

ProviderWhat You Need
Claude Pro/MaxAnthropic subscription
ChatGPT Plus/ProOpenAI subscription (Codex)
GitHub CopilotCopilot subscription
Google Gemini CLIFree Google account
Google AntigravityFree Google account (sandbox with Gemini, Claude, GPT)

API Key Providers

Set an environment variable or add to auth.json:

ProviderEnvironment Variable
AnthropicANTHROPIC_API_KEY
OpenAIOPENAI_API_KEY
Google GeminiGEMINI_API_KEY
MistralMISTRAL_API_KEY
GroqGROQ_API_KEY
xAI (Grok)XAI_API_KEY
OpenRouterOPENROUTER_API_KEY
Hugging FaceHF_TOKEN
CerebrasCEREBRAS_API_KEY
OpenCodeOPENCODE_API_KEY

Cloud Providers

ProviderSetup
Amazon BedrockAWS credentials (AWS_PROFILE or IAM keys)
Azure OpenAIAZURE_OPENAI_API_KEY + AZURE_OPENAI_BASE_URL
Google Vertex AIgcloud auth application-default login + GOOGLE_CLOUD_PROJECT

Choosing a Model

During a Session

Press Ctrl+P to cycle between available models, or use the /model command to open the model selector with fuzzy search.

From the Command Line

# Use a specific model
soma --model claude-sonnet-4

# Use provider/model format
soma --model openai/gpt-4o

# Set thinking level
soma --model sonnet:high

# Limit model cycling to specific models
soma --models claude-sonnet,claude-haiku,gpt-4o

# List all available models
soma --list-models

# Search for models
soma --list-models gemini

Set a Default Provider

soma --provider openai

Storing API Keys

Option 1: Environment Variables

Add to your shell profile (~/.zshrc, ~/.bashrc):

export ANTHROPIC_API_KEY=sk-ant-...

Option 2: Auth File

Store keys in ~/.soma/agent/auth.json (created with 0600 permissions — user-only access):

{
  "anthropic": { "type": "api_key", "key": "sk-ant-..." },
  "openai": { "type": "api_key", "key": "sk-..." }
}

The key field supports three formats:

FormatExampleDescription
Literal"sk-ant-..."Used directly
Env var"MY_API_KEY"Reads the named environment variable
Shell command"!security find-generic-password -ws 'anthropic'"Executes command, uses stdout

Shell commands work great with password managers:

{
  "anthropic": {
    "type": "api_key",
    "key": "!op read 'op://vault/anthropic/api-key'"
  }
}

Option 3: OAuth Login

For subscription-based providers, use /login inside a session:

/login

Select your provider, follow the browser flow. Tokens are stored and refresh automatically.

Custom Providers (Ollama, LM Studio, etc.)

Add any OpenAI-compatible provider via ~/.soma/agent/models.json:

Ollama

{
  "providers": {
    "ollama": {
      "baseUrl": "http://localhost:11434/v1",
      "api": "openai-completions",
      "apiKey": "ollama",
      "models": [
        { "id": "llama3.1:8b" },
        { "id": "qwen2.5-coder:7b" }
      ]
    }
  }
}

LM Studio

{
  "providers": {
    "lm-studio": {
      "baseUrl": "http://localhost:1234/v1",
      "api": "openai-completions",
      "apiKey": "lm-studio",
      "models": [
        { "id": "your-loaded-model" }
      ]
    }
  }
}

OpenRouter (Access 100+ Models)

{
  "providers": {
    "openrouter": {
      "baseUrl": "https://openrouter.ai/api/v1",
      "apiKey": "OPENROUTER_API_KEY",
      "api": "openai-completions",
      "models": [
        {
          "id": "anthropic/claude-sonnet-4",
          "name": "Claude Sonnet 4 (OpenRouter)"
        }
      ]
    }
  }
}

Custom API Proxy

{
  "providers": {
    "my-proxy": {
      "baseUrl": "https://proxy.example.com/v1",
      "api": "anthropic-messages",
      "apiKey": "MY_PROXY_KEY",
      "headers": {
        "x-custom-header": "value"
      },
      "models": [
        {
          "id": "claude-sonnet-4",
          "name": "Claude via My Proxy"
        }
      ]
    }
  }
}

Supported APIs

API TypeUse For
openai-completionsOllama, LM Studio, vLLM, most local servers
openai-responsesOpenAI Responses API
anthropic-messagesAnthropic or Anthropic-compatible proxies
google-generative-aiGoogle Generative AI

Model Options

FieldDefaultDescription
id(required)Model identifier sent to API
namesame as idDisplay name for model selector
reasoningfalseSupports extended thinking
input["text"]["text"] or ["text", "image"]
contextWindow128000Context window in tokens
maxTokens16384Max output tokens
costall zeros{ "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 } (per million tokens)

Compatibility Settings

Some servers don’t fully implement the OpenAI API. Use compat to work around this:

{
  "providers": {
    "ollama": {
      "baseUrl": "http://localhost:11434/v1",
      "api": "openai-completions",
      "apiKey": "ollama",
      "compat": {
        "supportsDeveloperRole": false,
        "supportsReasoningEffort": false
      },
      "models": [{ "id": "llama3.1:8b" }]
    }
  }
}
Compat FieldDescription
supportsDeveloperRoleUse developer vs system role for system prompt
supportsReasoningEffortSupports reasoning_effort parameter
supportsUsageInStreamingSupports streaming usage stats
maxTokensFieldUse max_completion_tokens or max_tokens

Override Built-in Providers

Route a built-in provider through a proxy without losing its model list:

{
  "providers": {
    "anthropic": {
      "baseUrl": "https://my-proxy.example.com/v1"
    }
  }
}

All built-in models stay available. Your existing auth continues to work.

File Locations

FilePurposeLocation
auth.jsonAPI keys + OAuth tokens~/.soma/agent/auth.json
models.jsonCustom providers + models~/.soma/agent/models.json
settings.jsonEngine settings~/.soma/agent/settings.json

models.json reloads every time you open /model — edit it during a session without restarting.

Troubleshooting

”No models available”

  • Check that at least one API key is set or /login was completed
  • Run soma doctor to verify your setup
  • Try soma --list-models to see what’s detected

Model not appearing in /model

  • Verify your models.json syntax (must be valid JSON)
  • Check baseUrl is reachable: curl <baseUrl>/models
  • Ensure apiKey resolves (env var must be set)

Ollama models not working

  • Add "compat": { "supportsDeveloperRole": false } to the provider
  • Make sure Ollama is running: ollama serve
  • Check the model is pulled: ollama list

Authentication errors

  • For subscription providers: try /logout then /login
  • For API keys: verify with echo $ANTHROPIC_API_KEY | head -c 10
  • Auth file keys override env vars — check both