QVeris
MULTI-PROVIDER INTEGRATION GUIDE多供应商集成指南

Call Multiple LLMs
Through One Production API
一个生产 API
调用多个 LLM

Use one endpoint to call GPT, Claude, Gemini, and other model families without hiding the differences that matter. This guide shows the request contract, capability catalog, adapters, routing, fallback, secrets, testing, cost controls, and evidence a production multi-LLM API needs.

用一个端点调用 GPT、Claude、Gemini 等模型,同时保留真正影响结果的差异。本指南将完整说明生产级多模型 API 所需的请求契约、能力目录、适配器、路由、故障切换、密钥隔离、测试、成本控制与调用证据。

One API contract routing to GPT Claude and Gemini through capability-aware adapters

TL;DR

One API means one client contract

Applications share authentication, request envelopes, tracing and operational controls.

Models are not interchangeable

GPT, Claude and Gemini differ by model, endpoint, version, tools, context, modalities and policy.

Aliases need capability checks

Resolve a workload alias only to endpoints that satisfy required behavior.

Keep native transparency

Return provider and model identity, request IDs, usage, route and transformations with normalized output.

一个 API 意味着一个客户端契约

应用共享认证、请求封装、Tracing 与运营控制。

模型不可互换

GPT、Claude 与 Gemini 因模型、端点、版本、工具、上下文、模态与策略而异。

别名需要能力检查

工作负载别名只能解析到满足必需行为的端点。

保留原生透明度

随标准化输出返回供应商与模型身份、请求 ID、用量、路由与转换。

What the unified call should standardize统一调用应标准化什么

Standardize application concerns that are genuinely common: service identity, tenant, trace context, workload alias, messages, timeout, budget, required capabilities and a stable response envelope. Resolve the alias from a versioned catalog before provider translation.

标准化真正通用的应用关注点:服务身份、租户、调用链上下文、工作负载别名、Message、超时、预算、所需能力与稳定响应封装。在供应商转换前,从版本化目录解析别名。

Do not force every feature into the common denominator. Use typed extensions for provider-specific tools, reasoning, schema, media or caching controls. Reject missing required capabilities before the call rather than silently degrading them.

不要把所有功能都压进最低共同分母。供应商特定工具、推理、结构定义、媒体或缓存控制应使用类型化扩展;在调用前拒绝缺失必需能力,而不是静默降级。

One-API integration layers单一 API 集成层

Layer Best fit最适合 Verify before choosing选择前验证
Canonical request规范请求 One SDK sends identity, messages, workload alias and required capabilities.一个 SDK 发送身份、Message、工作负载别名与所需能力。 Keep timeout, budget, trace and tenant explicit; avoid provider assumptions in app code.显式保留超时、预算、调用链与租户,避免应用代码假设供应商。
Capability catalog能力目录 Model aliases map to eligible versions and endpoints.模型别名映射到合格版本与端点。 Source and refresh tools, schemas, context, modalities, region, policy and lifecycle.为工具、结构定义、上下文、模态、区域、策略与生命周期标注来源并刷新。
Router路由器 Filters and chooses among eligible GPT, Claude or Gemini endpoints.在合格 GPT、Claude 或 Gemini 端点中过滤并选择。 Record candidate set, exclusions, policy, route and fallback conditions.记录候选集、排除项、策略、路由与故障切换条件。
Provider adapters供应商适配器 Translate canonical fields to supported native semantics.把规范字段转换为受支持的原生语义。 Contract-test tools, streams, structured output, errors and usage for each adapter.为每个适配器契约测试工具、流、结构化输出、错误与用量。
Response envelope响应封装 Applications receive stable fields plus native evidence.应用接收稳定字段与原生证据。 Preserve provider, model, request ID, route, attempts, usage units and transformations.保留供应商、模型、请求 ID、路由、尝试、用量单位与转换。

Build the common contract around workloads围绕工作负载构建通用契约

Workload alias

Name the task contract, not a vendor model, when portability is required.

Required capabilities

Declare tools, schema, modalities, context, streaming, region and policy as hard flags.

Typed extensions

Allow opt-in native features without pretending every provider supports them.

Evidence fields

Keep canonical and native identity together for debugging, cost and audit.

工作负载别名

需要可移植性时,命名任务契约而不是供应商模型。

必需能力

把工具、结构定义、模态、上下文、流、区域与策略声明为硬性 Flag。

类型化扩展

允许选择原生功能,同时不假装每个供应商都支持。

证据字段

把规范与原生身份并存,用于调试、成本与审计。

Prove each model path验证每条模型路径

  • Create golden requests for each production workload and required capability combination.
  • Run contract tests against every eligible GPT, Claude and Gemini endpoint.
  • Diff outputs, tools, streams, errors, usage and latency under real payloads.
  • Canary route changes and block on workload-specific invariant regressions.
  • Keep provider-native direct paths for diagnosis and tested rollback.
  • 为每个生产负载与必需能力组合建立 Golden 请求。
  • 对每个合格 GPT、Claude 与 Gemini 端点运行契约测试。
  • 在真实请求数据下对比输出、工具、流、错误、用量与延迟。
  • 灰度路由变更,并在工作负载特定不变量回归时阻断。
  • 保留供应商原生直连路径,用于诊断与已测试回滚。

Use aliases above typed provider adapters在类型化供应商适配器之上使用别名

The application sends a canonical request with workload alias and required capabilities. A catalog expands eligible endpoints; a policy router selects one; a typed adapter maps the request. The normalized response returns with provider-native identity and evidence. Unsupported requirements fail before execution, and fallback uses only verified equivalents.

应用发送带工作负载别名与所需能力的规范请求;目录展开合格端点,策略路由器选择一个,类型化适配器映射请求。标准化响应携带供应商原生身份与证据返回。不支持的要求在执行前失败,故障切换也只使用已验证等价项。

Production rule: one client contract must not become one vague promise that every model behaves the same.

生产规则:一个客户端契约不能变成“所有模型行为相同”的模糊承诺。

Design the canonical request contract first先设计统一请求契约

Start with the behavior your application needs, not with one provider's JSON. A useful request includes a workload alias, ordered messages, required capabilities, optional preferences, timeout, maximum spend, tenant, trace context, and an idempotency key where retries can create side effects. Keep hard requirements separate from preferences: JSON schema compliance may be required, while lower latency may only be a preference.

先从应用需要的行为出发,而不是照搬某一家供应商的 JSON。一个实用的统一请求应包含工作负载别名、有序消息、必需能力、可选偏好、超时、最高预算、租户、调用链上下文,以及可能产生副作用时使用的幂等键。必须满足的条件与偏好要分开:例如严格遵守 JSON Schema 可以是硬要求,而较低延迟只是偏好。

The response should be equally deliberate. Return normalized content and tool calls, then attach the selected provider, exact model version, gateway request ID, upstream request ID, routing policy, attempt count, usage units, finish reason, and any lossy transformation. That envelope gives application code stability without erasing the evidence needed for debugging.

响应也应有清晰边界。先返回标准化内容与工具调用,再附上最终供应商、准确模型版本、网关请求 ID、上游请求 ID、路由策略、尝试次数、用量、结束原因和任何有损转换。这样既能稳定应用代码,也不会抹掉排障所需的证据。

Filter by capability before optimizing the route先按能力筛选,再优化路由

Build a versioned capability catalog for every allowed model endpoint. Record supported input modalities, tool calling, parallel tools, structured output, streaming, context limits, regions, data handling, lifecycle status, and known workload quality. Refresh the catalog from official documentation and verified probes; do not let a marketing model name stand in for an executable capability claim.

为每个允许使用的模型端点建立带版本的能力目录,记录输入模态、工具调用、并行工具、结构化输出、流式响应、上下文限制、可用区域、数据处理方式、生命周期状态,以及已验证的工作负载质量。目录应依据官方文档与实际探测持续更新,不能把营销名称当作可执行的能力承诺。

Routing is a two-stage decision. First remove candidates that fail a hard requirement. Only then rank the eligible set by quality, latency, availability, price, residency, or tenant policy. Record both the candidate set and exclusion reasons so “smart routing” remains explainable when a result or bill is challenged.

路由应分两步:先剔除不满足硬要求的候选项,再在合格集合中按质量、延迟、可用性、价格、数据驻留或租户策略排序。候选集合与排除原因都要记录,出现结果争议或账单异常时,“智能路由”才可解释。

Keep provider translation inside typed adapters把供应商差异收进类型化适配器

Each adapter owns translation to and from one native API: message roles, system instructions, tools, schemas, media, sampling controls, stop reasons, error types, rate-limit headers, and usage. The adapter must reject an impossible mapping. Silently dropping a schema, tool choice, image, or safety option creates a successful HTTP response with the wrong behavior.

每个适配器只负责一种原生 API 的双向转换,包括消息角色、系统指令、工具、Schema、媒体、采样参数、停止原因、错误类型、限流响应头与用量。无法等价映射时必须明确拒绝。静默丢弃 Schema、工具选择、图片或安全设置,会得到 HTTP 成功却行为错误的结果。

Avoid a lowest-common-denominator API. Keep a compact portable core and expose namespaced, typed extensions for features that are intentionally provider-specific. The caller then knows whether it requested portable behavior or accepted a lock-in boundary.

不要把统一 API 压缩成“最低公分母”。通用核心应保持精简;确实属于供应商特性的能力,则通过带命名空间、可校验的扩展显式开放。调用方因此能清楚知道自己是在使用可迁移能力,还是主动接受了绑定边界。

Treat streams, tools, and structured output as protocols把流、工具与结构化输出当作协议处理

A stream is more than text chunks. Providers can emit content deltas, reasoning events, tool arguments, citations, usage, and terminal metadata in different orders. Define a gateway event model, test chunk assembly and cancellation, and preserve the native terminal reason. Once bytes have reached the caller, automatic fallback can duplicate text or produce a mixed answer.

流式响应不只是文本分片。不同供应商会以不同顺序发送内容增量、推理事件、工具参数、引用、用量与结束元数据。网关应定义自己的事件模型,测试分片组装与取消,并保留原生结束原因。一旦内容已发给调用方,自动切换模型可能造成重复文本或拼接出混合答案。

Tool calling also needs a lifecycle: validate arguments, authorize the tool, attach a stable call ID, record the result, and decide who resumes the model. For structured output, test the exact schema constructs each route supports and validate the final payload again at the gateway boundary.

工具调用也需要完整生命周期:校验参数、授权工具、分配稳定调用 ID、记录结果,并明确由谁继续模型对话。结构化输出则要测试每条路由真正支持的 Schema 语法,并在网关边界再次校验最终结果。

Use one client key without flattening upstream secrets统一客户端密钥,但不要混用上游密钥

Applications should authenticate to the gateway with a scoped credential tied to service, tenant, environment, and allowed workloads. Provider keys stay encrypted behind the gateway. Give each secret an owner, environment, provider account, rotation schedule, allowed routes, and emergency revocation path. A single leaked client token should not reveal or unlock every upstream account.

应用应使用限定范围的凭证访问网关,凭证要绑定服务、租户、环境与允许的工作负载。各供应商密钥则加密保存在网关之后,分别记录负责人、环境、供应商账号、轮换计划、允许路由与紧急吊销路径。某个客户端令牌泄露时,不应暴露或解锁全部上游账号。

Enforce per-tenant quotas, concurrency, model allowlists, and spend limits at the gateway. Redact prompts and credentials from logs by default, and make any payload retention an explicit policy rather than an observability side effect.

网关还应按租户执行配额、并发限制、模型白名单与预算上限。日志默认脱敏提示词和凭证;如果确实需要保留请求正文,应由明确的数据策略控制,而不是把它当作可观测性的附带结果。

Make fallback narrow, bounded, and observable让故障切换范围小、次数有限且可观察

Retry transient failures with capped exponential backoff and jitter, while respecting provider retry guidance. Fallback may select only a prequalified equivalent for the same workload. Carry the original deadline and budget across attempts; do not give every retry a fresh allowance. Stop on authentication, invalid requests, policy rejections, and unsupported features.

短暂故障可按供应商建议进行带抖动的指数退避,但次数必须有上限。故障切换只能选择已为同一工作负载验证过的等价项。所有尝试共用原始截止时间与预算,不能每次重试都重新获得一份额度。认证失败、请求无效、策略拒绝或能力不支持时应立即停止。

Never blindly replay a request after a partial stream or a side-effecting tool call. Use idempotency keys, tool execution ledgers, and explicit resume rules where recovery is necessary. Return the attempt history so operators can distinguish a slow first route from a successful but expensive fallback chain.

部分流已经输出,或工具已经产生副作用后,不能盲目重放请求。确需恢复时,应使用幂等键、工具执行账本与明确的续跑规则。响应中保留尝试历史,运维人员才能区分“首条路由较慢”和“经过多次昂贵切换后才成功”。

Measure accepted work, not just token price衡量可接受结果,而不只比较 Token 单价

Normalize usage into a cost record without pretending provider units are identical. Store native input, output, cached, reasoning, image, audio, and tool-related units alongside the provider's billed amount and currency. Join that record to workload, tenant, route, latency, retries, quality score, and acceptance outcome.

可以把用量整理成统一成本记录,但不要假设各家计费单位完全相同。原生输入、输出、缓存、推理、图片、音频及工具相关用量,应与供应商实际计费金额和币种一起保存,再关联工作负载、租户、路由、延迟、重试次数、质量评分与最终是否被接受。

The useful comparison is cost per accepted task, not the advertised price per token. Track success rate, p50 and p95 latency, schema-valid rate, tool success, fallback rate, budget overruns, and quality by alias. Alerts should include the gateway request ID, chosen path, policy version, and upstream evidence.

真正有价值的指标是“每个可接受任务的成本”,而不是宣传页上的 Token 单价。应按别名跟踪成功率、p50/p95 延迟、Schema 合格率、工具成功率、故障切换率、预算超支与质量。告警中要包含网关请求 ID、最终路径、策略版本和上游证据。

Production checklist for one multi-LLM API多模型统一 API 上线检查清单

  • Version the request, response, aliases, capability catalog, and routing policy independently.
  • Fail before execution when no route satisfies every hard capability and policy requirement.
  • Contract-test every adapter for text, streams, tools, schemas, errors, cancellation, and usage.
  • Keep upstream secrets isolated; scope client credentials and budgets by tenant and workload.
  • Canary alias changes, compare golden workloads, and retain a tested rollback path.
  • Expose selected provider, exact model, transformations, attempts, native IDs, usage, and cost.
  • 分别对请求、响应、别名、能力目录与路由策略做版本管理。
  • 没有任何路由满足全部硬性能力与策略要求时,在执行前明确失败。
  • 逐个适配器测试文本、流、工具、Schema、错误、取消与用量。
  • 隔离上游密钥,并按租户与工作负载限制客户端凭证和预算。
  • 别名变更先灰度,用 Golden 工作负载对比,并保留已测试的回滚路径。
  • 暴露最终供应商、准确模型、转换、尝试记录、原生 ID、用量与成本。

Seven mistakes that make a unified API unsafe让统一 API 失控的七个常见错误

Mistake错误 Production consequence生产后果 Better control更好的控制
Lowest-common-denominator contract最低公分母契约Important features disappear silently.关键能力被静默丢弃。Portable core plus typed extensions.通用核心加类型化扩展。
Opaque smart routing不透明的智能路由Quality and cost changes cannot be explained.质量与成本变化无法解释。Log candidates, exclusions, policy, and route.记录候选、排除原因、策略与路由。
Hidden provider identity隐藏供应商身份Incidents and invoices cannot be reconciled.事故与账单无法核对。Return exact native identity and request IDs.返回准确原生身份与请求 ID。
Unlimited retry chains无限重试链One request multiplies latency and spend.一次请求放大延迟与支出。Shared deadline, shared budget, capped attempts.共享截止时间与预算,并限制次数。
Stale model catalog模型目录过期Aliases point to retired or changed behavior.别名指向已退役或行为改变的模型。Official sources, probes, owners, and expiry.官方来源、探测、负责人和过期时间。
Semantic fallback语义不等价的切换Availability rises while answer quality falls.可用性上升,答案质量却下降。Prequalify alternates per workload.按工作负载预先验证备用项。
Shared upstream keys共享上游密钥Leaks gain broad provider access.泄露后可访问大范围供应商资源。Scoped client auth and isolated secrets.限定客户端权限并隔离上游密钥。

One model API plus one capability interface一个模型 API 加一个能力接口

The unified model API gives an agent consistent inference access. QVeris gives that agent Discover → Inspect → Call access to external APIs, tools, services and live data. Stack them as model interface plus capability interface, sharing workload identity and trace context.

统一模型 API 为智能体提供一致推理访问;QVeris 以 Discover → Inspect → 调用提供外部 API、工具、服务与实时数据访问。把两者叠加为模型接口与能力接口,并共享工作负载身份与调用链上下文。

Keep one request shape and explicit model aliases保持一个请求 Shape 与显式模型别名

A unified endpoint is useful only when callers can predict what each alias means. Use product-owned aliases, return the native provider and exact model in the response metadata, and reject unknown aliases instead of silently choosing a default.

统一端点只有在调用方能预测每个别名含义时才有价值。使用产品自有别名,在响应 Metadata 中返回原生供应商与准确模型,并拒绝未知别名,而不是静默选择默认值。

One endpoint, two workload aliases一个端点,两个工作负载别名
for alias in support-fast support-quality; do
  curl --fail-with-body "$LLM_GATEWAY_BASE_URL/chat/completions"     -H "Authorization: Bearer $LLM_GATEWAY_API_KEY"     -H "Content-Type: application/json"     -H "X-Workload: support-answer"     -d "{"model":"$alias","messages":[{"role":"user","content":"Reply $alias OK"}]}"
done
  • Document each alias's capability, quality gate, region, lifecycle, and owner.
  • Require response metadata to expose chosen provider, native model, policy version, and usage.
  • Run the same golden workload against every alias before changing its mapping.
  • 记录每个别名的能力、质量门槛、区域、生命周期与 Owner。
  • 要求响应 Metadata 暴露最终供应商、原生模型、Policy Version 与用量。
  • 修改别名 Mapping 前,用同一 Golden 工作负载测试所有候选。

Verified implementation reference: OpenAI Chat Completions reference.

实施参考已根据官方资料核验:OpenAI Chat Completions reference

FAQ

Can one API call GPT, Claude, and Gemini?

Yes. A gateway can expose one client endpoint and translate a canonical request into each native API. Capability checks still matter because tools, schemas, streams, modalities, limits, and errors differ.

Should the API expose provider names?

Yes. Applications may use stable workload aliases, but response metadata should preserve the selected provider, exact model, policy version, request IDs, usage, and transformations.

Can fallback switch model families?

Only when the alternate passes the workload's capability, policy, region, and quality contract. Never replay partial streams or side-effecting tool calls without a safe idempotency design.

Does one API key mean sharing provider keys?

No. Applications use a scoped gateway credential. Provider keys remain encrypted upstream secrets with separate ownership, rotation, quotas, and audit records.

What should a multi-LLM API normalize?

Normalize identity, messages, aliases, timeouts, budgets, required capabilities, trace context, common output fields, and error classes. Keep typed extensions and native evidence where behavior is not equivalent.

How should teams test a unified LLM API?

Run versioned golden workloads and adapter contract tests across every eligible route. Compare tools, schemas, streams, errors, usage, latency, safety behavior, and task quality.

一个 API 能调用 GPT、Claude 和 Gemini 吗?

可以。网关可以提供一个客户端端点,再把统一请求转换为各家的原生 API。但工具、Schema、流、模态、限制和错误并不完全相同,因此仍需能力校验。

API 应暴露供应商名称吗?

应该。应用可以使用稳定的工作负载别名,但响应元数据仍应保留最终供应商、准确模型、策略版本、请求 ID、用量与转换记录。

故障切换能切换模型家族吗?

只有备用项同时通过工作负载的能力、策略、区域与质量契约时才可以。部分流或有副作用的工具调用,不应在缺少安全幂等设计时重放。

一个 API 密钥等于共享供应商密钥吗?

不等于。应用使用限定范围的网关凭证;供应商密钥仍是隔离加密的上游秘密,分别管理负责人、轮换、配额与审计记录。

多模型 API 应该标准化什么?

标准化身份、消息、别名、超时、预算、必需能力、调用链、通用输出字段与错误类别;不能等价的行为则保留类型化扩展和原生证据。

如何测试统一 LLM API?

对每条合格路由运行带版本的 Golden 工作负载与适配器契约测试,比较工具、Schema、流、错误、用量、延迟、安全行为与任务质量。

Official sources and further reading官方资料与延伸阅读