From 0e1988fffde70a69ac24df9f9769c835db57f147 Mon Sep 17 00:00:00 2001 From: Infer by Flow7 Date: Thu, 3 Dec 2026 17:26:26 -0500 Subject: [PATCH 1/3] feat: add Infer to the built-in provider catalog Infer is an OpenAI-compatible API with up to four routes per model, picked by the model ID suffix (:low-cost, :balanced, :stable, :official). The catalog entry uses the existing OpenAI implementation with base URL https://infer.flow7.org/v1, INFER_API_KEY and the default model infer/claude-opus-5-5:low-cost. Infer is already in the models.dev snapshot, so the provider ID, the default model and the example resolve against it without exemptions. merge_consecutive_messages stays unset because the message-merging probe was not run. Tests cover the alias request (with an opt-in live test behind DOCKER_AGENT_RUN_INFER_LIVE_TEST), automatic selection and the merge gating. Docs add a provider page, a nav entry, the credentials row and an examples/infer.yaml recipe. Signed-off-by: Infer by Flow7 --- docs/data/nav.yml | 2 + docs/providers/infer/index.md | 136 ++++++++++++++++++ docs/providers/overview/index.md | 1 + examples/README.md | 1 + examples/infer.yaml | 17 +++ pkg/config/auto_test.go | 16 +++ pkg/model/provider/catalog/providers.json | 9 ++ .../openai/system_message_merge_test.go | 1 + .../provider/openai_alias_providers_test.go | 8 ++ 9 files changed, 191 insertions(+) create mode 100644 docs/providers/infer/index.md create mode 100644 examples/infer.yaml diff --git a/docs/data/nav.yml b/docs/data/nav.yml index 9d1b498ec3..8f8d66d39d 100644 --- a/docs/data/nav.yml +++ b/docs/data/nav.yml @@ -215,6 +215,8 @@ url: /providers/hopbase/ - title: Hugging Face url: /providers/huggingface/ + - title: Infer + url: /providers/infer/ - title: Local Models url: /providers/local/ - title: Lunaroute diff --git a/docs/providers/infer/index.md b/docs/providers/infer/index.md new file mode 100644 index 0000000000..cd3e3d1ca6 --- /dev/null +++ b/docs/providers/infer/index.md @@ -0,0 +1,136 @@ +--- +title: "Infer" +description: "Use Infer models with Docker Agent." +keywords: docker agent, ai agents, model providers, llm, infer +weight: 145 +canonical: https://docs.docker.com/ai/docker-agent/providers/infer/ +--- + +## Overview + +[Infer](https://infer.flow7.org) serves models from Anthropic, OpenAI, Google, +xAI and others through an OpenAI-compatible API. Each model is offered on up to +four routes, and the suffix of the model ID picks the route: `:low-cost`, +`:balanced`, `:stable` or `:official`. Docker Agent includes Infer as a built-in +provider in its embedded provider catalog. + +## Setup + +1. Create an account and an API key on the + [API keys page](https://infer.flow7.org/app#/keys). +2. Add wallet credit before the first call. Infer is prepaid, and a request the + wallet can't cover returns an `insufficient_credits` error. +3. Set the environment variable: + + ```bash + export INFER_API_KEY=your-api-key + ``` + +## Usage + +### Inline Syntax + +Infer model IDs start with `infer/` themselves, as Infer's `/v1/models` and +models.dev list them, so the inline reference repeats the prefix: + +```yaml +agents: + root: + model: infer/infer/claude-opus-5-5:low-cost + description: Assistant using Infer + instruction: You are a helpful assistant. +``` + +Docker Agent splits the inline reference at the first slash, so +`infer/claude-opus-5-5:low-cost` is sent to Infer unchanged and is also the ID +looked up in models.dev. + +### Named Model + +The `model` value is the model ID exactly as listed: + +```yaml +models: + infer_model: + provider: infer + model: infer/claude-opus-5-5:low-cost + max_tokens: 8192 + +agents: + root: + model: infer_model + description: Assistant using Infer + instruction: You are a helpful assistant. +``` + +When Infer is selected automatically from available credentials, the default +model is `infer/claude-opus-5-5:low-cost`. + +## Available Models + +The [models page](https://infer.flow7.org/models) lists every model with its +routes and prices. With a key, `/v1/models` returns the model IDs you can call: + +```bash +curl https://infer.flow7.org/v1/models \ + -H "Authorization: Bearer $INFER_API_KEY" +``` + +Use an ID from the response unchanged as the `model` value, for example +`infer/claude-sonnet-5-5:low-cost`, `infer/gpt-6.2-sol:low-cost` or +`infer/grok-4.7:low-cost`. The response also lists image and video generation +models, which can't be used as chat models. + +## Pricing and Model Metadata + +Infer is in the [models.dev](https://models.dev/) catalog. For the Infer models +that models.dev carries, `docker agent models --provider infer` and the model +picker list them, and Docker Agent reads their prices, context limits and input +types from models.dev. If models.dev is unavailable, Docker Agent falls back to +its embedded catalog snapshot. + +A model ID that models.dev doesn't list still works. Docker Agent then has no +price or context limit for it, and attachment detection falls back to +text-only; see +[Attachment Capability Overrides](../../configuration/models/index.md#attachment-capability-overrides). + +## Reasoning and Tool Calls + +Infer keeps a model's reasoning across tool calls only when the +`reasoning_details` record from its reply is sent back. Docker Agent sends +earlier reasoning back as `reasoning_content` text instead, so that reasoning +isn't carried over: + +- Docker Agent sends no thinking settings for Claude models through this + provider, so `thinking_budget` has no effect on them. +- Gemini tool calls depend on that record coming back. Tool calls with Gemini + models through this provider weren't checked, so the examples on this page + use Claude. + +## How It Works + +Infer is an entry in Docker Agent's built-in provider catalog +(`pkg/model/provider/catalog/providers.json`) that uses the existing OpenAI +implementation: + +- **API type:** OpenAI-compatible Chat Completions (`openai_chatcompletions`) +- **Base URL:** `https://infer.flow7.org/v1` +- **Token variable:** `INFER_API_KEY` + +See the [Infer API docs](https://infer.flow7.org/docs) for request options. + +## Example: Code Assistant + +```yaml +agents: + coder: + model: infer/infer/claude-sonnet-5-5:low-cost + description: Code assistant using Infer + instruction: | + You are an expert programmer. + Write clean code and follow language best practices. + toolsets: + - type: filesystem + - type: shell + - type: think +``` diff --git a/docs/providers/overview/index.md b/docs/providers/overview/index.md index 0080bb1bc0..915d495c6b 100644 --- a/docs/providers/overview/index.md +++ b/docs/providers/overview/index.md @@ -81,6 +81,7 @@ Use this table to find a built-in provider's config key and authentication metho | Straitly | [`straitly`](../straitly/index.md) | `STRAITLY_API_KEY` | | Morse | [`morse`](../morse/index.md) | `MORSE_API_KEY` | | UncensoredLabs | [`uncensoredlabs`](../uncensoredlabs/index.md) | `UNCENSOREDLABS_API_KEY` | +| Infer | [`infer`](../infer/index.md) | `INFER_API_KEY` | | Azure OpenAI | `azure` | `AZURE_API_KEY` + `base_url` (override the key with `token_key`) | | [Ollama](../local/index.md) | `ollama` | None (local; optional `base_url`) | | GitHub Copilot | `github-copilot` | `GITHUB_TOKEN` or `GH_TOKEN` (PAT with `copilot` scope) | diff --git a/examples/README.md b/examples/README.md index b540516a11..1985cc5d2f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -236,6 +236,7 @@ remote MCP endpoints. | [`straitly.yaml`](straitly.yaml) | Straitly multi-model gateway (`straitly`). | | [`morse.yaml`](morse.yaml) | Morse open-weight model provider (`morse`). | | [`uncensoredlabs.yaml`](uncensoredlabs.yaml) | UncensoredLabs standard and abliterated model provider (`uncensoredlabs`). | +| [`infer.yaml`](infer.yaml) | Infer multi-model API with per-model routes (`infer`). | | [`cloudflare-workers-ai.yaml`](cloudflare-workers-ai.yaml) | Cloudflare Workers AI edge-hosted open models. | | [`cloudflare-ai-gateway.yaml`](cloudflare-ai-gateway.yaml) | Cloudflare AI Gateway multi-provider router. | | [`grok.yaml`](grok.yaml) | xAI Grok model. | diff --git a/examples/infer.yaml b/examples/infer.yaml new file mode 100644 index 0000000000..2153229114 --- /dev/null +++ b/examples/infer.yaml @@ -0,0 +1,17 @@ +# yaml-language-server: $schema=../agent-schema.json + +models: + infer_model: + provider: infer + model: infer/claude-opus-5-5:low-cost + +agents: + root: + model: infer_model + description: Assistant using Infer + instruction: | + You are a helpful assistant. + toolsets: + - type: filesystem + - type: shell + - type: think diff --git a/pkg/config/auto_test.go b/pkg/config/auto_test.go index b52e31f671..6fb1baae76 100644 --- a/pkg/config/auto_test.go +++ b/pkg/config/auto_test.go @@ -163,6 +163,13 @@ func TestAvailableProviders_NoGateway(t *testing.T) { }, expectedProvider: "uncensoredlabs", }, + { + name: "infer api key present", + envVars: map[string]string{ + "INFER_API_KEY": "test-key", + }, + expectedProvider: "infer", + }, { name: "baseten api key present", envVars: map[string]string{ @@ -490,6 +497,15 @@ func TestAutoModelConfig(t *testing.T) { expectedModel: "deepseek-v4.1-flash-fast", expectedMaxTokens: 32000, }, + { + name: "infer provider", + envVars: map[string]string{ + "INFER_API_KEY": "test-key", + }, + expectedProvider: "infer", + expectedModel: "infer/claude-opus-5-5:low-cost", + expectedMaxTokens: 32000, + }, { name: "orcarouter provider", envVars: map[string]string{ diff --git a/pkg/model/provider/catalog/providers.json b/pkg/model/provider/catalog/providers.json index 2a0e71f593..0746073981 100644 --- a/pkg/model/provider/catalog/providers.json +++ b/pkg/model/provider/catalog/providers.json @@ -205,6 +205,15 @@ "UNCENSOREDLABS_API_KEY" ] }, + { + "name": "infer", + "api_type": "openai", + "base_url": "https://infer.flow7.org/v1", + "default_model": "infer/claude-opus-5-5:low-cost", + "token_env_vars": [ + "INFER_API_KEY" + ] + }, { "name": "baseten", "merge_consecutive_messages": true, diff --git a/pkg/model/provider/openai/system_message_merge_test.go b/pkg/model/provider/openai/system_message_merge_test.go index 6f87f1b1c6..fb7b3202ad 100644 --- a/pkg/model/provider/openai/system_message_merge_test.go +++ b/pkg/model/provider/openai/system_message_merge_test.go @@ -248,6 +248,7 @@ func TestShouldMergeConsecutiveMessages_Gating(t *testing.T) { {"straitly, no base_url", &latest.ModelConfig{Provider: "straitly", Model: "deepseek/deepseek-v4-1-flash"}, false}, {"morse, no base_url", &latest.ModelConfig{Provider: "morse", Model: "deepseek/deepseek-v4.1-flash"}, false}, {"uncensoredlabs, no base_url", &latest.ModelConfig{Provider: "uncensoredlabs", Model: "deepseek-v4.1-flash-fast"}, false}, + {"infer, no base_url", &latest.ModelConfig{Provider: "infer", Model: "infer/claude-opus-5-5:low-cost"}, false}, {"ovhcloud", &latest.ModelConfig{Provider: "ovhcloud", Model: "Qwen3.5-397B-A17B"}, true}, {"open-model host alias cerebras", &latest.ModelConfig{Provider: "cerebras", Model: "qwen-3-coder-480b"}, true}, {"open-model host fireworks", &latest.ModelConfig{Provider: "fireworks", Model: "accounts/fireworks/models/kimi-k3"}, true}, diff --git a/pkg/model/provider/openai_alias_providers_test.go b/pkg/model/provider/openai_alias_providers_test.go index 185ad202f9..76bb758adc 100644 --- a/pkg/model/provider/openai_alias_providers_test.go +++ b/pkg/model/provider/openai_alias_providers_test.go @@ -156,6 +156,14 @@ var openAIAliasProviders = []openAIAliasProvider{ greeting: "Hello from UncensoredLabs", liveOptInEnvVar: "DOCKER_AGENT_RUN_UNCENSOREDLABS_LIVE_TEST", }, + { + provider: "infer", + envVar: "INFER_API_KEY", + testKey: "test-infer-key", + model: "infer/claude-opus-5-5:low-cost", + greeting: "Hello from Infer", + liveOptInEnvVar: "DOCKER_AGENT_RUN_INFER_LIVE_TEST", + }, { provider: "deepseek", envVar: "DEEPSEEK_API_KEY", From 0becfb5c7d92bd931cfb65526c5227a923b11de6 Mon Sep 17 00:00:00 2001 From: Infer by Flow7 Date: Fri, 4 Dec 2026 22:16:18 -0500 Subject: [PATCH 2/3] fix(catalog): don't advertise video input for Infer models Infer's models.dev entries list video input for some Gemini models, but Docker Agent sends Infer requests through Chat Completions, whose attachment conversion has no video part, so the model picker advertised an input the model never receives. Add unsupported_input_modalities to the provider catalog. Model choices leave those models.dev input modalities out, and the Infer entry lists video. Attachment handling is unchanged: a video attachment is still dropped with a warning during conversion, and the Infer page now says so. Signed-off-by: Infer by Flow7 --- docs/providers/infer/index.md | 14 +++++- pkg/model/provider/catalog/catalog.go | 3 ++ pkg/model/provider/catalog/catalog_test.go | 8 ++++ pkg/model/provider/catalog/providers.json | 3 ++ pkg/runtime/modelcatalog/catalog.go | 18 +++++++- pkg/runtime/modelcatalog/catalog_test.go | 52 ++++++++++++++++++++++ 6 files changed, 94 insertions(+), 4 deletions(-) diff --git a/docs/providers/infer/index.md b/docs/providers/infer/index.md index cd3e3d1ca6..fc84c2330d 100644 --- a/docs/providers/infer/index.md +++ b/docs/providers/infer/index.md @@ -86,14 +86,24 @@ models, which can't be used as chat models. Infer is in the [models.dev](https://models.dev/) catalog. For the Infer models that models.dev carries, `docker agent models --provider infer` and the model picker list them, and Docker Agent reads their prices, context limits and input -types from models.dev. If models.dev is unavailable, Docker Agent falls back to -its embedded catalog snapshot. +types from models.dev, except video (see [Attachments](#attachments)). If +models.dev is unavailable, Docker Agent falls back to its embedded catalog +snapshot. A model ID that models.dev doesn't list still works. Docker Agent then has no price or context limit for it, and attachment detection falls back to text-only; see [Attachment Capability Overrides](../../configuration/models/index.md#attachment-capability-overrides). +## Attachments + +Docker Agent sends Infer requests through Chat Completions, and its Chat +Completions conversion has no content part for video. Some Infer models list +video input in models.dev, but the model picker doesn't show video for Infer +models. A video attachment is dropped with a warning before the request is +sent, so the model never sees it. Setting `capabilities.video: true` on the +model doesn't change this. + ## Reasoning and Tool Calls Infer keeps a model's reasoning across tool calls only when the diff --git a/pkg/model/provider/catalog/catalog.go b/pkg/model/provider/catalog/catalog.go index fc7b99bebf..9f3f524450 100644 --- a/pkg/model/provider/catalog/catalog.go +++ b/pkg/model/provider/catalog/catalog.go @@ -51,6 +51,9 @@ type Provider struct { // OpenAIVendor identifies genuine OpenAI model hosts, gating OpenAI-only wire fields. // Speaking the OpenAI-compatible protocol alone does not qualify. OpenAIVendor bool `json:"openai_vendor,omitempty"` + // UnsupportedInputModalities lists models.dev input modalities that requests to this + // provider cannot carry, such as video over Chat Completions; the model picker omits them. + UnsupportedInputModalities []string `json:"unsupported_input_modalities,omitempty"` // Headers supplies default HTTP headers; user http_headers override them case-insensitively. Headers map[string]string `json:"headers,omitempty"` // QueryParams maps string-valued provider_opts keys to URL query parameter names. diff --git a/pkg/model/provider/catalog/catalog_test.go b/pkg/model/provider/catalog/catalog_test.go index 3f9f9190e8..c95da2164b 100644 --- a/pkg/model/provider/catalog/catalog_test.go +++ b/pkg/model/provider/catalog/catalog_test.go @@ -45,6 +45,14 @@ func TestEmbeddedProviders(t *testing.T) { assert.NotEmpty(t, key) assert.NotEmpty(t, param) } + assert.Len(t, slices.Compact(slices.Sorted(slices.Values(alias.UnsupportedInputModalities))), len(alias.UnsupportedInputModalities)) + for _, modality := range alias.UnsupportedInputModalities { + switch modality { + case "image", "pdf", "audio", "video": + default: + t.Errorf("unknown unsupported_input_modalities entry %q", modality) + } + } switch alias.APIFlavor { case "", APIFlavorOpenAI, APIFlavorOpenAICompatible, APIFlavorGateway: default: diff --git a/pkg/model/provider/catalog/providers.json b/pkg/model/provider/catalog/providers.json index 0746073981..c99ab90a64 100644 --- a/pkg/model/provider/catalog/providers.json +++ b/pkg/model/provider/catalog/providers.json @@ -212,6 +212,9 @@ "default_model": "infer/claude-opus-5-5:low-cost", "token_env_vars": [ "INFER_API_KEY" + ], + "unsupported_input_modalities": [ + "video" ] }, { diff --git a/pkg/runtime/modelcatalog/catalog.go b/pkg/runtime/modelcatalog/catalog.go index d3b420dc3c..cb6cd04584 100644 --- a/pkg/runtime/modelcatalog/catalog.go +++ b/pkg/runtime/modelcatalog/catalog.go @@ -438,7 +438,9 @@ func (r *Catalog) populateCatalogMetadata(ctx context.Context, choice *ModelChoi } // applyCatalogMetadata copies pricing/limit/modality information from a -// models.dev Model entry onto a ModelChoice. +// models.dev Model entry onto a ModelChoice. Input modalities that requests to +// the choice's provider cannot carry are left out, so callers set +// choice.Provider first. func applyCatalogMetadata(choice *ModelChoice, m *modelsdev.Model) { if m == nil { return @@ -452,10 +454,22 @@ func applyCatalogMetadata(choice *ModelChoice, m *modelsdev.Model) { } choice.ContextLimit = m.Limit.Context choice.OutputLimit = m.Limit.Output - choice.InputModalities = slices.Clone(m.Modalities.Input) + choice.InputModalities = deliverableInputModalities(choice.Provider, m.Modalities.Input) choice.OutputModalities = slices.Clone(m.Modalities.Output) } +// deliverableInputModalities returns a copy of the models.dev input modalities +// without those the provider's catalog entry marks unsupported, so the picker +// never advertises an attachment the request would drop. +func deliverableInputModalities(providerID string, input []string) []string { + unsupported := catalog.Lookup(providerID).UnsupportedInputModalities + return slices.DeleteFunc(slices.Clone(input), func(modality string) bool { + return slices.ContainsFunc(unsupported, func(u string) bool { + return strings.EqualFold(u, modality) + }) + }) +} + // isEmbeddingModel returns true if the model is an embedding model // based on its family or name fields from models.dev. func isEmbeddingModel(family, name string) bool { diff --git a/pkg/runtime/modelcatalog/catalog_test.go b/pkg/runtime/modelcatalog/catalog_test.go index 7246e937eb..d36360f8b2 100644 --- a/pkg/runtime/modelcatalog/catalog_test.go +++ b/pkg/runtime/modelcatalog/catalog_test.go @@ -24,6 +24,14 @@ func (m *mockCatalogStore) GetDatabase(context.Context) (*modelsdev.Database, er return m.db, nil } +func (m *mockCatalogStore) GetModel(_ context.Context, id modelsdev.ID) (*modelsdev.Model, error) { + model, ok := m.db.Providers[id.Provider].Models[id.Model] + if !ok { + return nil, fmt.Errorf("model %q not found", id.String()) + } + return &model, nil +} + func TestIsEmbeddingModel(t *testing.T) { t.Parallel() @@ -505,3 +513,47 @@ func TestBuildCatalogChoices_CanonicalProviders(t *testing.T) { } } } + +// TestCatalogMetadata_OmitsUnsupportedInputModalities verifies that the picker +// does not advertise an input modality the provider's requests cannot carry: +// Infer goes through Chat Completions, whose conversion drops video +// attachments, so the video input listed by models.dev is left out for Infer +// models while other providers keep it. +func TestCatalogMetadata_OmitsUnsupportedInputModalities(t *testing.T) { + t.Parallel() + + allInputs := []string{"text", "image", "video", "audio", "pdf"} + gemini := modelsdev.Model{ + Name: "Gemini 3.1 Pro Preview", + Modalities: modelsdev.Modalities{Input: allInputs, Output: []string{"text"}}, + } + r := &Catalog{ + Store: &mockCatalogStore{db: &modelsdev.Database{Providers: map[string]modelsdev.Provider{ + "infer": {Models: map[string]modelsdev.Model{"infer/gemini-3.1-pro-preview:official": gemini}}, + "google": {Models: map[string]modelsdev.Model{"gemini-3.1-pro-preview": gemini}}, + }}}, + Config: &Config{ + EnvProvider: environment.NewMapEnvProvider(map[string]string{ + "INFER_API_KEY": "test-key", + "GOOGLE_API_KEY": "test-key", + }), + }, + } + + inputs := make(map[string][]string) + for _, choice := range r.buildCatalogChoices(t.Context()) { + inputs[choice.Ref] = choice.InputModalities + } + require.Contains(t, inputs, "infer/infer/gemini-3.1-pro-preview:official") + require.Contains(t, inputs, "google/gemini-3.1-pro-preview") + assert.Equal(t, []string{"text", "image", "audio", "pdf"}, inputs["infer/infer/gemini-3.1-pro-preview:official"]) + assert.Equal(t, allInputs, inputs["google/gemini-3.1-pro-preview"]) + + // A configured Infer model is filtered the same way. + configured := ModelChoice{Provider: "infer"} + r.populateCatalogMetadata(t.Context(), &configured, "infer", "infer/gemini-3.1-pro-preview:official") + assert.Equal(t, []string{"text", "image", "audio", "pdf"}, configured.InputModalities) + + // The models.dev entry itself is left untouched. + assert.Equal(t, []string{"text", "image", "video", "audio", "pdf"}, gemini.Modalities.Input) +} From 606ebf2aa60b48472f9b88000e6293cc89e46980 Mon Sep 17 00:00:00 2001 From: Infer by Flow7 Date: Fri, 4 Dec 2026 22:31:28 -0500 Subject: [PATCH 3/3] docs(infer): record the streamed tool call round trips A streamed tool call round trip completed through the Infer provider with infer/claude-opus-5-5:low-cost, infer/gemini-3.1-pro-preview:official and infer/gemini-3.8-flash:low-cost: the CLI, built from this branch, sent the tool result back in a second request and the model used it, even though Docker Agent doesn't send Infer's reasoning_details record back. Replace the note that Gemini tool calls weren't checked; the note that reasoning isn't carried over stays. Signed-off-by: Infer by Flow7 --- docs/providers/infer/index.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/providers/infer/index.md b/docs/providers/infer/index.md index fc84c2330d..05f00bfbfb 100644 --- a/docs/providers/infer/index.md +++ b/docs/providers/infer/index.md @@ -113,9 +113,10 @@ isn't carried over: - Docker Agent sends no thinking settings for Claude models through this provider, so `thinking_budget` has no effect on them. -- Gemini tool calls depend on that record coming back. Tool calls with Gemini - models through this provider weren't checked, so the examples on this page - use Claude. +- Without the record, a streamed tool call round trip still completed with + `infer/claude-opus-5-5:low-cost`, `infer/gemini-3.1-pro-preview:official` + and `infer/gemini-3.8-flash:low-cost`: the tool result went back in a second + request and the model used it. Other models weren't checked. ## How It Works