provider-adapter-canonical-openai

provider-adapter-canonical-openai is a cursor rule for Cursor from AlphaBitCore/nexus-gateway. It costs 0 tokens per session (1,739 once invoked), scanned A, original, Apache-2.0.

A coding rule for connecting different AI providers through one internal request and response format based on OpenAI's chat-completions format. Each provider adapter translates between that shared format and the provider's own API format.

In plain words
What is it for?
Use it when adding or changing adapters for providers such as Anthropic, Gemini, Bedrock, Cohere, or Replicate.
Why use it?
It keeps routing, caching, logging, and other gateway code independent of provider-specific request details.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/. Also seen: reads .claude/ paths.

Good fit Use it when adding or changing adapters for providers such as Anthropic, Gemini, Bedrock, Cohere, or Replicate.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/alphabitcore/nexus-gateway/provider-adapter-canonical-openai
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/AlphaBitCore/nexus-gateway

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for provider-adapter-canonical-openai

README.md
[![agentmods](https://agentmods.dev/badge/rules/alphabitcore/nexus-gateway/provider-adapter-canonical-openai/github.svg)](https://agentmods.dev/rules/alphabitcore/nexus-gateway/provider-adapter-canonical-openai)
Your own site
<a href="https://agentmods.dev/rules/alphabitcore/nexus-gateway/provider-adapter-canonical-openai"><img src="https://agentmods.dev/badge/rules/alphabitcore/nexus-gateway/provider-adapter-canonical-openai/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for provider-adapter-canonical-openai

Your own site · 80×15
<a href="https://agentmods.dev/rules/alphabitcore/nexus-gateway/provider-adapter-canonical-openai"><img src="https://agentmods.dev/badge/rules/alphabitcore/nexus-gateway/provider-adapter-canonical-openai.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,739 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.01739
Opus 5 $0.00000 $0.00870
Sonnet 5 $0.00000 $0.00348
Haiku 4.5 $0.00000 $0.00174

Measured 10d ago against content hash 296a8990d172, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

provider-adapter-canonical-openai scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

// Verified again 2026-05-12 via direct curl. Confirmed: deprecation, not a transient.
.cursor/rules/provider-adapter-canonical-openai.mdc · 130 lines

How it starts

The opening of the file, as written. The whole thing — 130 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Provider adapter: canonical = OpenAI shape (binding)

You are editing a provider adapter or its codec. The 8 binding rules below come from docs/developers/architecture/services/ai-gateway/provider-adapter-architecture.md §3a. Apply to every adapter PR.

Read docs/developers/architecture/services/ai-gateway/provider-adapter-architecture.md §3a BEFORE editing.

Rule 1 — Canonical format is OpenAI chat-completions shape

All internal flow (router input, cache key, hook input, audit envelope, request lineage) sees the canonical form, which is OpenAI's shape:

model · messages[] · max_tokens / max_completion_tokens · temperature · top_p · top_k ·
stream · stop · response_format · tools[] · tool_choice · parallel_tool_calls ·
metadata · stream_options

New canonical fields require an architecture-doc PR — adapters do not add canonical fields unilaterally.

Rule 2 — Each non-OpenAI adapter owns its full bidirectional translation

When you add an Anthropic / Gemini / Bedrock / Cohere / Replicate codec:

  • SchemaCodec.EncodeRequest does canonical → wire.
  • SchemaCodec.DecodeResponse does wire → canonical.

The OpenAI side stays pure (identity codec) — it never carries case-statements for "this came from Anthropic so do X". OpenAI shape is the bus; every other shape adapter wires itself into the bus.

Rule 3 — Per-model wire quirks belong in their own adapter

HTTP-400-deprecations, parameter renames, mandatory clamping — they live in the adapter that talks to that wire. Not in cross-adapter case-statements in spec_adapter.go's shared helpers.

Quirk Lives in
claude-opus-4-7 deprecates temperature/top_p/top_k specs/anthropic/codec/codec.go::anthropicModelRejectsSamplingParams
claude-4.x rejects temperature + top_p together specs/anthropic/codec/codec.go::anthropicModelRejectsTempTopPTogether
gpt-5.x / o-series rename max_tokens → max_completion_tokens + strip temp/top_p specs/openai/rewrites (ApplyReasoningRewrites, wired as the OpenAI PassthroughRewrite)
kimi-k2.5/k2.6 require temperature=1 specs/compat/moonshot/rewrites.go (ApplyRewrites, wired as the Moonshot PassthroughRewrite)

Read the full file on GitHub · 130 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 130 lines · 0 tokens per session scan A 296a8990d172

Subscribe to this mod's changes

provider-adapter-canonical-openai is a cursor rule published in the GitHub repository AlphaBitCore/nexus-gateway (23 stars, last pushed yesterday), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,739 tokens. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.