Providers
Swival supports local, hosted, and API-based model providers:
- LM Studio — local inference
- llama.cpp — local llama.cpp server
- HuggingFace Inference API — hosted inference
- OpenRouter — multi-provider access through a single API
- Anthropic — Claude models through the Anthropic API with an API key
- Generic (OpenAI-compatible) — any OpenAI-compatible server
- Apple Foundation Models — experimental, local Apple Foundation Models server
- Google Gemini API — Google's models via API key
- Gemini Enterprise Agent Platform — Gemini through Google Cloud (formerly Vertex AI)
- ChatGPT Plus/Pro — OpenAI models via your existing subscription
- AWS Bedrock — models hosted on AWS
- Command (External Program) — shell out to an external program
Switching Between Providers
If you use more than one provider regularly, define named profiles in your config instead of retyping flags each time. See Profiles for the full syntax.
[profiles.local]
provider = "lmstudio"
model = "qwen3-coder-next"
[profiles.gpt]
provider = "chatgpt"
model = "gpt-6.2-sol"
reasoning_effort = "high"
[profiles.claude]
provider = "anthropic"
model = "claude-opus-5-5"
Then switch with --profile at startup, or /profile mid-session:
swival --profile local "quick task"
swival --profile gpt "hard task"
swival --profile claude "review this patch"
swival> /profile gpt
Profiles switch the whole stack at once.
To change only the model within the current provider, use the /model command in the REPL.
With no argument it opens a picker over the models the provider can serve right now.
/model NAME switches directly, and favorites you star in the picker are remembered across sessions.
GEAP and the command provider have no model listing, so the picker shows the models you already use instead, and /model ID still works.
See Usage for the details.
The sections below document each provider's flags, authentication, and behavior in detail.
LM Studio
LM Studio is the default provider and usually requires no flags when the local server is already running with a loaded model.
At startup, Swival calls http://127.0.0.1:1234/api/v1/models unless you override --base-url. It looks for the first model entry with type: "llm" and a non-empty loaded_instances array, then extracts the model identifier and current context length from that payload. If no loaded model is found, Swival exits and asks you to load a model or pass --model explicitly.
If LM Studio is running on another host or port, set --base-url.
swival --base-url http://192.168.1.100:1234 "task"
If you want to bypass auto-discovery, pass --model.
swival --model "qwen3-coder-next" "task"
If you pass --max-context-tokens, Swival may reload the model through LM Studio's /api/v1/models/load endpoint.
swival --max-context-tokens 131072 "task"
If the requested value already matches the loaded context length, no reload happens.
When a reload is required, it can take noticeable time depending on model size and hardware.
HuggingFace Inference API
For HuggingFace, --model is required and must be in org/model format. Authentication comes from HF_TOKEN by default or --api-key if you pass one explicitly. If you don't know which model to pick, the /model command in the REPL (and the first-run wizard) opens an explorer over the models currently served by inference providers, with per-provider context and pricing details plus each model's aggregate tool-support status; see Usage.
export HF_TOKEN=hf_your_token_here
swival --provider huggingface --model zai-org/GLM-5.3 "task"
Serverless HuggingFace endpoints often expose smaller context windows than local deployments, so long multi-turn coding sessions can hit context pressure sooner. When --max-context-tokens is not set, Swival looks the window up in LiteLLM's model registry; set the flag explicitly if your model is not listed there.
For dedicated endpoints, keep the same model identifier and pass your endpoint URL and key.
swival --provider huggingface \
--model zai-org/GLM-5.3 \
--base-url https://xyz.endpoints.huggingface.cloud \
--api-key hf_your_key \
"task"
HuggingFace Inference Endpoints
HuggingFace Inference Endpoints let you deploy any supported model on dedicated infrastructure. Create an endpoint from the HuggingFace UI, then point Swival at it with --base-url.
swival --provider huggingface \
--model Qwen/Qwen3.5-35B-A3B \
--base-url https://tfg1ghx03o7xuv5p.us-east-1.aws.endpoints.huggingface.cloud
Most inference endpoints use vLLM as the serving backend. For tool calling to work, you must add the following to the Container Arguments field in your endpoint's configuration on HuggingFace:
--enable-auto-tool-choice --tool-call-parser qwen3_xml
The --tool-call-parser value depends on the model you deploy. For Qwen models use qwen3_xml, for other model families check the vLLM tool calling documentation for the correct parser name. Without these arguments, the endpoint will not return structured tool calls and Swival will not be able to use its tools.
For recently released models, the default vLLM version configured in Inference Endpoints may not support them yet. If you hit errors during model loading, set the Engine URI in your endpoint configuration to vllm/vllm-openai:latest to use a more recent build.
Some models served through vLLM leak internal reasoning markers like <think> tags into their responses. If you see these in the output, enable --sanitize-thinking to strip them. See Thinking Tag Sanitization for details.
Dedicated endpoints usually let you use the full deployed model context window rather than tighter serverless limits.
OpenRouter
For OpenRouter, --model is required and authentication comes from OPENROUTER_API_KEY or --api-key.
export OPENROUTER_API_KEY=sk_or_your_token_here
swival --provider openrouter --model z-ai/glm-5.3 "task"
If you use an OpenRouter-compatible custom endpoint, set --base-url.
swival --provider openrouter \
--model z-ai/glm-5.3 \
--base-url https://custom.openrouter.endpoint \
--api-key sk_or_key \
"task"
OpenRouter models vary widely in context limits. When --max-context-tokens is not set, Swival looks the window up in LiteLLM's model registry. If the model is missing from the registry, or you want a different limit, set the value explicitly:
swival --provider openrouter --model z-ai/glm-5.3 \
--max-context-tokens 131072 "task"
Pass bare model identifiers like z-ai/glm-5.3. If you accidentally include a provider prefix (e.g. openrouter/z-ai/glm-5.3), Swival detects and corrects the double prefix.
Anthropic
The anthropic provider uses the Anthropic API directly with an API key.
--model is required, and the key comes from ANTHROPIC_API_KEY or --api-key.
Create a key in the Claude Console.
export ANTHROPIC_API_KEY=sk-ant-your-key-here
swival --provider anthropic --model claude-opus-5-5 "task"
The same setup as a profile:
[profiles.claude]
provider = "anthropic"
model = "claude-opus-5-5"
reasoning_effort = "medium"
Pass bare model names like claude-opus-5-5.
An anthropic/ prefix is accepted and stripped.
With a key set, /model in the REPL lists the models your key can use.
Usage is billed to the Claude Console organization that owns the key. Max and Team plans come with monthly API credits. To use them, link a Console organization in your claude.ai billing settings and create the key there. Pro plans don't include API credits, so usage is billed per token. See Anthropic's monthly API credits page for the details.
Only API keys work. You can't sign in with your Claude account the way Claude Code does.
The session cost Swival shows uses list prices, even when monthly credits cover the usage.
If you used --provider generic --base-url https://api.anthropic.com before, switch to --provider anthropic.
You get cost reporting, automatic prompt caching, and the right context window without passing --max-context-tokens.
--reasoning-effort turns on extended thinking.
While thinking is on, Anthropic doesn't allow custom sampling or a forced tool choice.
Swival then ignores --temperature and --top-p and lets the model pick its tools.
Older models think within a fixed budget, which has to stay below --max-output-tokens.
If it doesn't fit, Swival shrinks it, or turns thinking off when the limit is too small for any budget.
Without thinking, Claude still won't take temperature and top_p together, so only --temperature is sent when you set both.
The newest models, such as claude-opus-5-5, accept neither sampling settings nor a forced tool choice, so those are always left out.
--seed isn't supported and is ignored.
Keys in extra_body, such as metadata or thinking, are added to the request as top-level fields.
The rules above apply to them too, and an explicit thinking setting wins over --reasoning-effort.
To use a proxy or gateway that speaks the Anthropic API, set --base-url to its root URL.
Swival adds /v1/messages itself and drops a trailing /v1.
swival --provider anthropic --model claude-opus-5-5 \
--base-url https://llm-gateway.example.com "task"
llama.cpp
llama.cpp runs GGUF models locally through llama-server, which exposes an OpenAI-compatible API. Start the server first, then point Swival at it.
Start llama-server with a model from HuggingFace:
llama-server \
--reasoning auto \
--fit on \
-hf unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q4_K_XL \
--temp 1.0 --top-p 0.95 --top-k 64
--reasoning auto lets the model use chain-of-thought when it helps. --fit on automatically sizes the context window and batch parameters to fit in available memory. The -hf flag downloads the model directly from HuggingFace on first run and caches it locally.
Once the server is listening (default port 8080), connect Swival:
swival --provider llamacpp "task"
Swival auto-detects the model name from the server, so --model is not required. It also auto-detects the context window: when --max-context-tokens is not set, it reads n_ctx from the server's /props endpoint, falling back to the OpenAI-compatible /v1/models payload. The default base URL is http://127.0.0.1:8080. To override either:
swival --provider llamacpp \
--base-url http://192.168.1.10:9090 \
--model my-model \
"task"
Generic (OpenAI-compatible)
The generic provider works with any server that exposes an OpenAI-compatible chat completions endpoint. This covers mlx_lm.server, ollama, vLLM, LocalAI, text-generation-webui, DeepSeek API, and similar tools.
Both --model and --base-url are required. Pass the server's root URL without /v1 — Swival appends it automatically. If your URL already ends in a version segment, that's fine too: /v1, or a provider that versions differently such as Z.AI's /api/paas/v4, is left untouched.
# mlx_lm.server
swival --provider generic \
--base-url http://127.0.0.1:8080 \
--model mlx-community/Qwen3-Coder-480B-A35B-4bit \
"task"
# ollama
swival --provider generic \
--base-url http://127.0.0.1:11434 \
--model qwen3:32b \
"task"
# DeepSeek API
export DEEPSEEK_API_KEY=sk-...
swival --provider generic \
--base-url https://api.deepseek.com \
--model deepseek-flash \
--api-key "$DEEPSEEK_API_KEY" \
"task"
# Z.AI — note the /v4 endpoint, which Swival keeps as-is
export ZAI_API_KEY=...
swival --provider generic \
--base-url https://api.z.ai/api/paas/v4 \
--model glm-5.3 \
--api-key "$ZAI_API_KEY" \
"task"
No API key is required for most local servers. If your server needs one, pass --api-key or set OPENAI_API_KEY.
export OPENAI_API_KEY=sk-...
swival --provider generic \
--base-url https://my-server.example.com \
--model my-model \
"task"
There is no model auto-discovery, so --model is always required. The context window, however, is auto-detected: when --max-context-tokens is not set, Swival probes the server's /v1/models payload for a context-length field (max_model_len, max_context_length, context_length, or context_window). Set --max-context-tokens manually if your server does not advertise the window.
Some providers gate access based on the User-Agent header. Use --user-agent to set it explicitly. For example, Kimi's coding API requires a KimiCLI user agent:
export KIMI_API_KEY=sk-kimi-...
swival --provider generic \
--base-url https://api.kimi.com/coding/v1 \
--model kimi-for-coding \
--api-key "$KIMI_API_KEY" \
--user-agent "KimiCLI/Swival" \
"task"
Apple Foundation Models
The applefm provider talks to a local Apple Foundation Models server that exposes an OpenAI-compatible endpoint at http://127.0.0.1:1976/v1. It is experimental, and tool support is limited — Swival sanitizes the tool schemas it sends, dropping any the Foundation Models runtime cannot handle.
swival --provider applefm "task"
Two models are available. Private Cloud Compute (pcc) is the default and the only one with enough room to do real work — roughly 32K tokens. The on-device system model tops out near 4K tokens and is experimental at best; select it with --model system. Swival defaults to pcc when you do not name a model.
The server does not report its context window, so Swival falls back to measured defaults (about 32K for pcc, about 4K for system). Override either with --max-context-tokens, and point at a non-default server with --base-url.
Google Gemini API
The google provider connects to Google's Gemini API through its OpenAI-compatible endpoint (/v1beta/openai).
--model is required. Authentication comes from --api-key, GEMINI_API_KEY, or OPENAI_API_KEY.
export GEMINI_API_KEY=...
swival --provider google \
--model gemini-3.8-flash \
"task"
When --max-context-tokens is not set, Swival auto-detects the context window from the model's known limits. If detection fails, context length is unknown and compaction may not trigger at the right time — set --max-context-tokens explicitly if you hit issues.
--base-url overrides the default endpoint if you need a custom one.
Gemini Enterprise Agent Platform
The geap provider connects to Google's Gemini models through Vertex AI / Gemini Enterprise Agent Platform. Unlike the google provider which uses a public API key, geap uses Google Cloud project credentials and is designed for enterprise setups.
--provider vertexai is accepted as an alias for --provider geap.
--model, --gcp-project, and --location are required. Authentication uses Google Application Default Credentials — no API key.
gcloud auth application-default login
swival --provider geap \
--gcp-project my-gcp-project \
--location us-central1 \
--model gemini-3.1-pro \
"task"
For service accounts, set GOOGLE_APPLICATION_CREDENTIALS instead of running the gcloud login:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/service-account.json
swival --provider geap \
--gcp-project my-gcp-project \
--location us-central1 \
--model gemini-3.1-pro \
"task"
--gcp-project can also be set via the GOOGLE_CLOUD_PROJECT environment variable:
export GOOGLE_CLOUD_PROJECT=my-gcp-project
swival --provider geap --location us-central1 --model gemini-3.1-pro "task"
Pass bare model names like gemini-3.1-pro. Do not include a vertex_ai/ prefix; Swival adds it automatically and rejects prefixed names with a clear error.
When --max-context-tokens is not set, Swival looks the window up in LiteLLM's model registry under the vertex_ai/ prefix. Set the flag explicitly if your model is not listed there.
In config:
provider = "geap"
model = "gemini-3.1-pro"
project = "my-gcp-project"
location = "us-central1"
ChatGPT Plus/Pro
The chatgpt provider lets you use OpenAI models through your existing ChatGPT Plus or ChatGPT Pro subscription, without needing a separate API key.
Authentication uses an OAuth device-code flow — on first use, Swival prints a device code and a verification URL to your terminal. Open the URL, enter the code, and authorize with your ChatGPT account. The resulting tokens are cached locally and refreshed automatically on subsequent runs.
If you need to pass an API key explicitly, set CHATGPT_API_KEY or use --api-key.
--model is required. There is no default model.
swival --provider chatgpt --model gpt-6.2-sol "task"
On the first run, you will see a device-code prompt with a URL and a code to enter in your browser. Once you complete the flow, the OAuth tokens are stored locally and refreshed automatically. To remove the cached tokens and force the device-code flow on the next run, use swival --logout.
Supported model names may change over time. Check OpenAI's documentation for the current model list and naming conventions.
When --max-context-tokens is not set, Swival looks the window up in LiteLLM's model registry. Set the flag explicitly if your model is not listed there.
Two environment variables are available for advanced use. CHATGPT_TOKEN_DIR overrides the default token storage directory, and CHATGPT_AUTH_FILE overrides the token filename or path. Use --base-url to override the API base URL.
export CHATGPT_TOKEN_DIR=/path/to/tokens
swival --provider chatgpt --model gpt-6.2-sol "task"
swival --logout
The --top-p, --seed, and tool_choice parameters are not supported by the ChatGPT Plus/Pro backend. Swival drops them automatically when using this provider.
The think and snapshot tools are not offered with this provider.
The backend rejects the whole response when a tool call looks like the model's own reasoning, and reports it as a usage-policy violation of your prompt.
The model reasons natively instead, and context compaction still applies.
Models like gpt-6.2-sol support tunable reasoning effort. Use --reasoning-effort to control how much the model thinks before responding:
swival --provider chatgpt --model gpt-6.2-sol --reasoning-effort high "task"
You can also combine reasoning effort with priority processing (service_tier: "priority") for faster responses without sacrificing quality. See the Service Tiers section.
No other configuration is needed.
AWS Bedrock
The bedrock provider connects to AWS Bedrock. It uses your existing AWS credentials — --api-key is not supported.
--model is required. Use the Bedrock model ID.
export AWS_ACCESS_KEY_ID=AKIA...
export AWS_SECRET_ACCESS_KEY=...
export AWS_REGION_NAME=us-east-2
swival --provider bedrock --model global.anthropic.claude-opus-5-5 "task"
Swival picks up credentials from environment variables, ~/.aws/credentials, ~/.aws/config, IAM roles, and SSO. To use a named profile, pass --aws-profile or set AWS_PROFILE.
swival --provider bedrock --model global.anthropic.claude-opus-5-5 \
--aws-profile bedrock "task"
Use --base-url to set the region, or pass a custom endpoint URL.
swival --provider bedrock --model global.anthropic.claude-opus-5-5 \
--base-url us-east-2 "task"
Note: the region env var is AWS_REGION_NAME, not AWS_DEFAULT_REGION.
When --max-context-tokens is not set, Swival reads the window from LiteLLM's model registry for the Bedrock model ID. Set the flag explicitly if your model is not listed there.
In the REPL, /model lists the inference profiles and models Bedrock offers in that region.
Your account may not have access to all of them.
Listing uses the bedrock:ListFoundationModels and bedrock:ListInferenceProfiles permissions.
With only one of them you get a shorter list.
It doesn't work when --base-url is a custom endpoint.
/model ID also takes ids that aren't on the list, like provisioned model ARNs.
For cross-region inference, use the regional prefix in the model ID (e.g. us., eu., apac.).
swival --provider bedrock --model us.anthropic.claude-opus-5-5 "task"
Extra Provider Parameters
Some models and servers accept parameters that go beyond the standard OpenAI API. Use --extra-body to pass them through. The value is a JSON object that gets forwarded directly to the API call.
For example, Qwen models served through vLLM can disable internal thinking mode:
swival --provider generic \
--base-url http://127.0.0.1:8000 \
--model Qwen/Qwen3.5-35B-A3B \
--extra-body '{"chat_template_kwargs": {"enable_thinking": false}}' \
"task"
You can also set this in config so you don't repeat it every time:
provider = "generic"
base_url = "http://127.0.0.1:8000"
model = "Qwen/Qwen3.5-35B-A3B"
extra_body = { chat_template_kwargs = { enable_thinking = false } }
The dictionary is forwarded as extra_body to the provider's API. Refer to your model or server documentation for supported parameters.
When using vLLM as the inference backend, models may leak internal reasoning markers like <think> tags into their output even with thinking disabled. Use --sanitize-thinking to strip them. See Thinking Tag Sanitization for details.
For reasoning effort specifically, Swival provides a dedicated --reasoning-effort flag instead of requiring extra_body. See Customization for details.
Command (External Program)
The command provider shells out to an external program instead of calling an API. This is useful when you want to wrap an existing CLI tool — such as codex exec --skip-git-repo-check --full-auto --ephemeral, ollama run, or a custom script — as Swival's backend.
The conversation transcript is written to the program's stdin, and the program's stdout is read back as the model response. --model holds the command string, which is split with shlex. --base-url and --api-key are ignored.
Tool calling is supported when command execution is enabled (the default, or via --commands). The external program can request tool execution by emitting <swival:call> XML blocks in its output.
Swival parses these, dispatches the tool calls, appends results to the transcript, and re-invokes the command. This loop continues (up to 20 rounds) until the program responds without tool calls. With --commands none, the native run_command and run_shell_command tools are not exposed, but the program can still call MCP, A2A, and skill tools through the same XML block protocol when those are configured.
swival --provider command --model "codex exec --skip-git-repo-check --full-auto --ephemeral" "task"
Or in config:
provider = "command"
model = "codex exec --skip-git-repo-check --full-auto --ephemeral"
Because the external program handles all model routing, there is no auto-discovery. If you set --max-context-tokens, Swival will apply output clamping and graduated compaction as usual; otherwise context management is left to the command itself.
Prompt Caching
When the model supports it, Swival marks the system prompt as cacheable. The system prompt and tool schemas then don't have to be processed again on every call.
For Claude, once the model has replied, Swival also marks the latest message. The next call can then read the conversation so far from the cache. That costs much less than sending it fresh, and it adds up quickly in long tool loops.
This only happens when requests go straight to Anthropic, OpenRouter, Bedrock (by region), or Vertex AI. Through a custom gateway, Swival only caches the system prompt, since it can't tell whether the gateway serves cached reads.
| Provider | Caching mechanism | Notes |
|---|---|---|
| Anthropic (native or via OpenRouter) | Explicit cache_control injected by Swival |
System prompt, plus the latest message once the model has replied |
| Google Gemini | Explicit cache_control injected by Swival |
Via openrouter/google/... or native google provider |
| AWS Bedrock | Explicit cache_control injected by Swival |
Claude models also get the latest message cached |
Vertex AI (geap/vertexai) |
Explicit cache_control injected by Swival |
Claude only. Gemini is skipped: Vertex AI rejects cached content with tools or a system prompt |
| OpenAI / Deepseek | Automatic (provider-side) | No annotation needed; prompts >1024 tokens cached automatically |
| LM Studio | None | Local inference, no server-side cache |
| Generic with custom base_url | Best effort | Annotation injected only when LiteLLM recognizes the model as cache-capable |
Swival only adds cache marks when LiteLLM knows the model supports caching (its supports_prompt_caching check).
They're added for every provider except LM Studio and Gemini on Vertex AI.
A provider that doesn't use them simply ignores them.
When diagnostics are enabled (the default unless --quiet is set), Swival prints cache hit and write stats to stderr after each turn:
Prompt cache: 4821 tokens cached
Prompt cache: 6103 tokens written to cache
To turn off Swival's cache marks, pass --no-prompt-cache.
Providers that cache automatically keep doing so.
If you set your own top-level cache_control through extra_body, Swival leaves caching to you and adds no marks of its own.