AI Features

AI Configuration

Shiro resolves AI providers from .shiro/config.yaml. Configure any OpenAI-compatible API or a local Ollama instance.

Config File

Shiro looks for AI config in this priority order:

  1. .shiro/config.yaml — project-local config (recommended)
  2. configs/models.yaml — repo-level fallback

Run shiro init to create the .shiro/ directory.

Full Example

.shiro/config.yaml
models:
  # Ollama — local model, no API key required
  codellama:
    provider: ollama
    model: codellama:34b
    base_url: http://localhost:11434

  llama3:
    provider: ollama
    model: llama3:8b
    base_url: http://localhost:11434

  # OpenAI
  gpt-4:
    provider: openai
    model: gpt-4
    base_url: https://api.openai.com/v1
    api_key: "{{env.OPENAI_API_KEY}}"

  # Any OpenAI-compatible endpoint (vLLM, LM Studio, etc.)
  custom-llm:
    provider: openai
    model: custom-model
    base_url: http://localhost:8000/v1
    api_key: "sk-custom-key"

  # Fully env-driven (good for CI)
  openai-custom:
    provider: openai
    model: "{{env.OPENAI_CUSTOM_MODEL}}"
    base_url: "{{env.OPENAI_CUSTOM_BASE_URL}}"
    api_key: "{{env.OPENAI_CUSTOM_API_KEY}}"

Model Fields

FieldTypeRequiredDescription
providerstringYesopenai or ollama
modelstringYesModel name (e.g. gpt-4o, llama3:8b, codellama:34b)
base_urlstringNoOverride the API base URL. Defaults to https://api.openai.com/v1 or http://localhost:11434
api_keystringopenai onlyBearer token for the API. Use {{env.VAR}} to read from environment
timeoutnumberNoRequest timeout in seconds. Default: 30
skip_tls_verifybooleanNoSkip TLS certificate verification for self-signed certs

Environment Variable Interpolation

Any config value wrapped in {{env.VAR}} is resolved from the environment at runtime. Shiro logs resolution attempts but never prints values.

yaml
api_key: "{{env.OPENAI_API_KEY}}"
model: "{{env.MY_MODEL}}"
base_url: "{{env.LLM_ENDPOINT}}"

If a referenced variable is not set, Shiro logs a warning and uses an empty string — which will cause the provider to fail at request time.

Using a Model in a Workflow

Reference any configured model name via the model field in an ai.generate step.

json
{
  "id": "summarize",
  "type": "ai.generate",
  "config": {
    "model": "gpt-4",
    "prompt": "Summarize the following diff:\n{{steps.diff.output.diff}}",
    "system": "You are a senior software engineer reviewing code.",
    "temperature": 0.3,
    "max_tokens": 512
  }
}

The model value must match a key in the models: section of your config file.

Default Provider Resolution

If provider is omitted from a step config, Shiro resolves the provider in this order:

  1. A provider named default in the config
  2. The only configured provider (if exactly one is defined)
  3. Falls back to default — which errors if it does not exist