Model configuration
LLM tiers, embedding models, and OpenAI-compatible providers when self-hosting ctxpipe.
When you self-host ctxpipe, you set the LLM and embedding models with environment variables. The service supports any OpenAI-compatible HTTP API. Use MODEL_PROVIDER to select OpenRouter-specific features, Azure (api-key auth), or Bedrock (native SDK with IAM SigV4).
MODEL_PROVIDER values
| Value | Auth (chat + embeddings) | MODEL_PROVIDER_URL default | Notes |
|---|---|---|---|
openai-like | Authorization: Bearer | https://openrouter.ai/api/v1 | Generic compatible API; no OpenRouter-only extras. |
openrouter | Authorization: Bearer | same | Enables plugins, prompt cache, reasoning flags, medium-tier model fallbacks. |
azure | api-key header only | required | Set your Azure OpenAI OpenAI-compatible base URL; override model name env vars for deployment IDs. |
bedrock | IAM SigV4 (ECS task role) | not required | Native Bedrock Runtime via AWS SDK. Set MODEL_BEDROCK_AWS_REGION or rely on AWS_REGION / AWS_DEFAULT_REGION. No MODEL_PROVIDER_API_KEY on AWS CDK deployments. |
If you do not set MODEL_PROVIDER, it defaults to openai-like. To keep the previous behavior (OpenRouter URL heuristics that added extras whenever the host was OpenRouter), set MODEL_PROVIDER=openrouter.
For Vertex and other gateways that expect Bearer and a base URL, use openai-like. If you route through OpenRouter, use openrouter.
AWS CDK Bedrock deployments
When you deploy with @ctxpipe/aws-cdk and modelProvider.kind: "bedrock", the construct does not store a static MODEL_PROVIDER_API_KEY. Backend and worker tasks receive IAM permissions (bedrock:InvokeModel, bedrock:InvokeModelWithResponseStream) and call Bedrock Runtime through the AWS SDK. They use the ECS task role (SigV4). Enable your chosen model IDs in the Bedrock console for the stack region before you use them. If the account is in an AWS Organization, also confirm that service control policies (SCPs) allow those same foundation-model ARNs. An SCP explicit deny overrides the task role. It shows as AccessDeniedException … explicit deny in a service control policy.
Workspace chat on Bedrock (OpenAI models only)
Workspace chat and ingestion on Bedrock use the Chat Completions API of Bedrock (bedrock-runtime.{region}.amazonaws.com/openai/v1). The backend signs each call with its AWS credentials (on ECS, the task role). The chat sandbox holds no AWS credential. This API serves only OpenAI models, so each tier (fast, medium, high) must be one of them, for example openai.gpt-oss-120b-1:0. With a model that the API does not serve, such as an Anthropic model, a chat turn fails with the error of Bedrock.
Bedrock embeddings (Cohere only)
When MODEL_PROVIDER=bedrock, embeddings use the native Bedrock Runtime API. Only Cohere embed models work. Other Bedrock embedding models do not work yet. On AWS CDK, when you do not set models.embedding, the default is Cohere Embed v4 through the inference profile of the geography in a US or EU Region (us.cohere.embed-v4:0, eu.cohere.embed-v4:0), else cohere.embed-v4:0. You can also use an inference-profile ID, for example global.cohere.embed-v4:0. If an SCP denies a profile ID, the error often names the base …/foundation-model/cohere.embed-v4:0 ARN.
The knowledge store
The knowledge store calls three models: an embedding model, an image model, and a decision model. The embedding model and the image model are on your model provider:
MODEL_PROVIDER | Embedding model (1024 dimensions) | Default image model (MODEL_VISION_NAME) |
|---|---|---|
openrouter, or openai-like on openrouter.ai | openai/text-embedding-3-large | openai/gpt-6.1-terra |
openai-like on another URL (OpenAI or a compatible server) | text-embedding-3-large | gpt-6.1-terra |
bedrock | In the US and the EU: Cohere Embed v4 through the inference profile of your geography (us.cohere.embed-v4:0, eu.cohere.embed-v4:0). In other Regions: amazon.titan-embed-text-v2:0 (Titan Text Embeddings V2) | In the US and the EU: Amazon Nova 2 Lite through the inference profile of your geography (us.amazon.nova-2-lite-v1:0, eu.amazon.nova-2-lite-v1:0). In other geographies: openai.gpt-6.1-terra through the geographic inference profile of your Region (for example apac.openai.gpt-6.1-terra) |
You cannot change the embedding model of the knowledge store:
MODEL_EMBEDDING_NAME sets only the embedding model of the model proxy
(/v1/embeddings). Each model provider is its own vector space: a change of the model
provider indexes each Workspace again. MODEL_VISION_NAME sets another image
model of your model provider. It must take image input and a JSON schema.
On Bedrock, a geographic inference profile (us., eu., apac. or us-gov.) can process an image in another Region of the same geography. ctxpipe never uses a global profile by default. In a Region outside these geographies, the default is the model id of the Region (openai.gpt-6.1-terra). To keep each image in your Region, set MODEL_VISION_NAME to a model that your Region serves. A new AWS account can call Nova 2 Lite, but not GPT-6.1 Terra. Nova 2 Lite is not an OpenAI model, so ctxpipe calls it through the Converse API of Bedrock.
On Bedrock in the US and the EU, the knowledge store embeds with Cohere
Embed v4, with up to 96 texts in each call. It uses the inference profile of
your geography (us. or eu.), which can process text in another Region of
the same geography. The default quotas of a new AWS account for these
profiles are 20 calls and 300,000 tokens a minute (Service Quotas, Amazon
Bedrock: "Cross-region model inference tokens per minute for Cohere Embed
V4"). A chunk has at most 2,048 characters, about 500 tokens. For example, a
Workspace with 2,000 chunks (about 200 Markdown files) gets its first
projection in about 3 minutes.
Bedrock has no other geographic profile of Cohere Embed v4, and its global profile can process text in any commercial Region. Thus in another Region, the knowledge store keeps the text in your Region: it embeds with Titan Text Embeddings V2, which takes one text in each call. The default quota of a new AWS account is 60 calls a minute ("On-demand model inference requests per minute for Amazon Titan Text Embeddings V2"), so the first projection embeds about 45 to 60 chunks a minute. For example, a Workspace with 2,000 chunks gets its first projection in about 35 to 45 minutes.
The worker paces its calls to the quota and retries each throttled call. A later projection embeds only the changed chunks. To make the first projection faster, ask AWS for a higher quota; the worker uses it with no change of settings.
When the embedding model changes, for example on an upgrade from Titan Text Embeddings V2 to Cohere Embed v4, the worker indexes each Workspace again, because the embedding model is part of the projection version. The hourly tip check queues the projection of each Workspace with vectors of another model. Until that projection is done, a search of that Workspace can give weaker results.
On OpenRouter, each call allows only zero data retention (ZDR) endpoints. On another model provider, the data terms of that provider apply.
The decision model is Jev on OpenRouter by default. Only OpenRouter serves Jev, so with another model provider you must set a decision model (see Decision model). On Bedrock, enable the embedding model (Cohere Embed v4 in the US and the EU, else Titan Text Embeddings V2) and the image model in the Amazon Bedrock console for your region.
With azure, openrouter or openai-like with no key, bedrock with no AWS
region, or no reachable decision model, the worker does not index a Workspace
in the knowledge store, and it logs the error
knowledge_plane.model_settings at start. No Workspace becomes ready, so
knowledge search, related-item lookups, and the graph do not work. The
knowledge tools give workspace_not_ready with the cause.
Quick Start (OpenRouter)
The default setup uses OpenRouter. Set your API key and start the stack:
MODEL_PROVIDER_API_KEY=sk-or-v1-... docker compose --profile deploy up -dLLM and embeddings both use OpenRouter by default. You do not need extra configuration.
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
MODEL_PROVIDER | No | openai-like | openai-like | openrouter | azure | bedrock - see table above. |
MODEL_PROVIDER_API_KEY | Yes* | - | API key for OpenAI-compatible providers. Not used for native Bedrock (MODEL_PROVIDER=bedrock). |
MODEL_PROVIDER_URL | No** | OpenRouter base when not azure | Base URL for OpenAI-compatible LLM/embeddings HTTP. Required for azure. Not required for native Bedrock. |
MODEL_BEDROCK_AWS_REGION | No | AWS_REGION / stack region | AWS region for Bedrock Runtime when MODEL_PROVIDER=bedrock. |
MODEL_PROVIDER_ALLOWLIST | No | - | OpenRouter provider slugs, separated by commas (for example openai,anthropic,azure). When set, each OpenRouter call goes only to these providers. When unset, OpenRouter can use any provider. It needs MODEL_PROVIDER=openrouter or a MODEL_PROVIDER_URL on openrouter.ai. A value that is not a slug list, or other model settings, stop the backend at start. |
MODEL_FAST_NAME | No | openai/gpt-6-luna?reasoning.effort=high | LLM model for the fast tier (OpenRouter slash ids). |
MODEL_MEDIUM_NAME | No | openai/gpt-6-luna?reasoning.effort=xhigh | LLM model for the medium tier. |
MODEL_HIGH_NAME | No | openai/gpt-6-luna?reasoning.effort=xhigh | LLM model for the high tier. |
MODEL_EMBEDDING_NAME | No | openai/text-embedding-3-large | Embedding model ID. |
MODEL_VISION_NAME | No | openai/gpt-6.1-terra | The one OpenRouter model that reads the images of the knowledge plane. It must take image input and have a ZDR endpoint on OpenRouter. A value of only spaces stops the backend at start. |
*Required for each provider except bedrock. The backend refuses model calls without it. For a provider that needs no key, such as Ollama, set any value that is not empty.
**Default MODEL_PROVIDER_URL is https://openrouter.ai/api/v1 for openai-like and openrouter so bundled default model IDs stay valid.
Each model call to OpenRouter allows only zero data retention (ZDR) endpoints, with no data collection. A model with no ZDR endpoint fails. A call goes to OpenRouter when MODEL_PROVIDER is openrouter, or when MODEL_PROVIDER_URL is on openrouter.ai. Another OpenAI-compatible API does not get these routing fields.
Decision model
The knowledge plane asks a decision model typed yes/no questions, for example "Does this candidate help answer the question?". A decision model answers with a probability, not with text. A chat model cannot replace it.
ctxpipe supports three decision providers:
DECISION_MODEL_PROVIDER | Default DECISION_MODEL_NAME | Endpoint |
|---|---|---|
openrouter (default) | typesafe/jev-1.14 (Jev) | OpenRouter Decisions API. Each call allows only ZDR endpoints. |
openai | gpt-6-luna | OpenAI Decisions API (/v1/decisions), or a compatible server at DECISION_MODEL_URL. |
gemini | gemini-decision-1 | Gemini Decisions API (/v1beta/decisions). |
| Variable | Required | Default | Description |
|---|---|---|---|
DECISION_MODEL_PROVIDER | No | openrouter | openrouter | openai | gemini. |
DECISION_MODEL_NAME | No | See the table above | The decision model ID of the provider. |
DECISION_MODEL_URL | No | The endpoint of the provider | The base URL, for example of an OpenAI-compatible server. |
DECISION_MODEL_API_KEY | Yes* | - | The API key of the decision provider. |
*When you do not set DECISION_MODEL_API_KEY, the decision model is Jev on OpenRouter, with MODEL_PROVIDER_URL and MODEL_PROVIDER_API_KEY. This works only when MODEL_PROVIDER is openrouter, or openai-like on openrouter.ai.
Bedrock has no decision model. With MODEL_PROVIDER=bedrock, set a decision provider and its key. Your embedding and image calls stay on Bedrock (see The knowledge store).
MODEL_PROVIDER=bedrock
DECISION_MODEL_PROVIDER=openai
DECISION_MODEL_API_KEY=sk-...ctxpipe tunes and tests the knowledge plane on Jev. ctxpipe does not test the OpenAI and Gemini decision models, and makes no claim about the quality of their results. Another decision model can give other probabilities for the same question.
How to Pick Models
LLM tiers
The service uses three tiers for different workloads:
| Tier | Use case | Default model spec |
|---|---|---|
| fast | Quick tasks, naming, planning | openai/gpt-6-luna?reasoning.effort=high |
| medium | Main agent, balanced cost/quality | openai/gpt-6-luna?reasoning.effort=xhigh |
| high | Complex reasoning, best quality | openai/gpt-6-luna?reasoning.effort=xhigh |
Override any tier with MODEL_FAST_NAME, MODEL_MEDIUM_NAME, or MODEL_HIGH_NAME. Use model IDs from your provider (OpenRouter: org/model-name; Bedrock on AWS CDK: vendor.model with dot, e.g. openai.gpt-6-luna?reasoning.effort=high).
Model spec query params
Append ?reasoning.effort=value to set the reasoning depth of a tier without extra environment variables. The supported values are none, minimal, low, medium, high, and xhigh. Each provider adapter maps this value to its upstream API (reasoning_effort on OpenAI-like / Azure / Bedrock Chat Completions; nested reasoning.effort on OpenRouter).
openai/gpt-6-luna?reasoning.effort=high
openai.gpt-6-luna?reasoning.effort=xhighTo disable reasoning in environment specs, use reasoning.effort=none. Do not use reasoning=false. Call sites can also pass getModel(..., { reasoning: false }), which merges reasoning.effort=none over the tier spec. ctxpipe sends model ids upstream without query strings.
When MODEL_PROVIDER=openrouter (or hosted ctxpipe, which sets it), the medium tier sends the OpenRouter models array. If the primary model fails (rate limits, downtime, moderation), routing tries the next distinct model IDs in order (MODEL_FAST_NAME, then MODEL_HIGH_NAME). ctxpipe removes duplicate base model ids from that chain. This does not apply to openai-like.
Embedding model
Important: The embedding model must support 2000 dimensions. The schema stores vectors in vector(2000); a model that is not compatible fails.
- OpenAI-compatible providers (OpenRouter, OpenAI, Vertex): Use models that accept a
dimensionsparameter, for exampleopenai/text-embedding-3-large(3072 dims, truncated to 2000). - Amazon Bedrock: Use a Cohere embed model ID (for example
cohere.embed-v4:0orglobal.cohere.embed-v4:0). Other Bedrock embed families are not supported yet. - Ollama: Use models with native 2000-dim support, e.g.
qwen3-embedding. SetMODEL_PROVIDER_URL=http://host:11434/v1andMODEL_EMBEDDING_NAME=qwen3-embedding(embeddings use{MODEL_PROVIDER_URL}/embeddings).
All providers use the same OpenAI-compatible embeddings API. Ollama exposes it at /v1/embeddings.
Provider Examples
OpenRouter (default host)
MODEL_PROVIDER_API_KEY=sk-or-v1-...
# Optional explicit mode (enables OpenRouter extras; default URL is OpenRouter either way):
# MODEL_PROVIDER=openrouter
MODEL_PROVIDER_URL=https://openrouter.ai/api/v1Azure OpenAI
MODEL_PROVIDER=azure
MODEL_PROVIDER_API_KEY=<your-azure-api-key>
MODEL_PROVIDER_URL=https://YOUR_RESOURCE.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT
# Set model env vars to your deployment names as needed.Amazon Bedrock (native SDK)
MODEL_PROVIDER=bedrock
MODEL_BEDROCK_AWS_REGION=us-east-1
MODEL_EMBEDDING_NAME=cohere.embed-v4:0 # or global.cohere.embed-v4:0; Cohere only on Bedrock
# ECS task role / instance profile supplies AWS credentials; no MODEL_PROVIDER_URL or API key.
# Org SCPs must allow the underlying foundation-model ARN (see AWS CDK Bedrock callout above).Ollama (local chat + embeddings)
MODEL_PROVIDER_URL=http://localhost:11434/v1
MODEL_PROVIDER_API_KEY=ollama # Ollama needs no key, but the value must not be empty
MODEL_FAST_NAME=<your-chat-model>
MODEL_MEDIUM_NAME=<your-chat-model>
MODEL_HIGH_NAME=<your-chat-model>
MODEL_EMBEDDING_NAME=qwen3-embedding
# For Docker: use http://host.docker.internal:11434/v1Set each model name. The defaults are OpenRouter model ids, which Ollama does not know.