Gateway compatibility testing
Run OpenAI and Anthropic compatibility suites and gateway certification checks
Esta página aún no está disponible en tu idioma.
This suite is the reproducible compatibility harness for Nexus’s OpenAI-compatible public API. It combines a pinned OpenAI OpenAPI snapshot with official SDK black-box tests against a running Nexus gateway.
Gold Truth
Section titled “Gold Truth”spec/openapi.yamlis a pinned copy of the official OpenAI OpenAPI specification.- Official SDKs are the runtime compatibility oracle.
The first runtime suite uses Python’s
openaipackage. - Raw HTTP tests cover cases that SDK type systems cannot express, such as unknown field passthrough.
Running The Python Suite
Section titled “Running The Python Suite”Start Nexus with deterministic provider fixtures, then run from test-suite/compat/python:
just testOr from nexus/:
just test-compatEquivalent without just:
uv run --project test-suite/compat/python pytest test-suite/compat/python/tests -n autoEnvironment:
NEXUS_COMPAT_BASE_URL: defaults tohttp://127.0.0.1:14450/v1NEXUS_API_KEY: required for tests against a live Nexus gatewayNEXUS_QUERY_BASE_URL: defaults tohttp://127.0.0.1:14461; used by image usage/cost analytics testsNEXUS_QUERY_TOKENorNEXUS_SERVICE_TOKEN: required for query analytics tests (gateway API keys cannot read the query API)NEXUS_COMPAT_PG_CONTAINER: defaults tovortex-dev-postgres-1; the analytics test resolves the API key’s org by querying this control-plane Postgres container viadocker execNEXUS_INGEST_BASE_URL: defaults tohttp://127.0.0.1:14457; analytics tests skip when ingest is unhealthyNEXUS_COMPAT_REQUIRE_INGEST: set to1(certification/CI) to make an unhealthy ingest a hard failure instead of a skip- Model selection reads
GET /v1/modelsand runs the OpenAI-compatible chat, tools, Responses, embeddings, and image cases once per pinned provider (openai/...,anthropic/...,azure-foundry-gov/...,bedrock-gov/..., and any other<provider>/prefix the catalog publishes). Each provider uses its cheapest model that advertises the capability. Direct OpenAI compare, session analytics, Agents SDK, and native Anthropic Messages stay on a single model so those suites do not fan out. SetNEXUS_COMPAT_PROVIDERS=openai,anthropicto restrict the matrix. NEXUS_COMPAT_MODEL: optional OpenAI chat pin. Replaces only the OpenAI slot; other chat providers still run.NEXUS_COMPAT_TOOL_MODEL: optional OpenAI tools pin for the OpenAI slot.NEXUS_COMPAT_REASONING_MODEL: optional OpenAI reasoning+tools pin for the OpenAI slot.NEXUS_COMPAT_RESPONSES_MODEL: optional OpenAI Responses pin for the OpenAI slot.NEXUS_COMPAT_BAND_MODEL: optional OpenAI long-context pin. When set (and present in the catalog), the expensive band-crossing probe runs against that row, or the cheapestopenai/row with more than one pricing band if the pin is stale. SetNEXUS_COMPAT_ENABLE_BAND_CROSSING=1to auto-pick without a pin. The probe is skipped by default because it sends a 272k-token prompt.NEXUS_COMPAT_EMBEDDING_MODEL: optional OpenAI embeddings pin for the OpenAI slot. Always use a pinned id; an unprefixedtext-embedding-3-smallcan match every embeddings-capable provider of that canonical model.NEXUS_COMPAT_EMBEDDING_MODELS: optional extra pinned ids merged into the embeddings listing check. They do not replace the per-provider matrix. Default coverage is the cheapest embeddings row for every provider that advertisescapabilities.embeddings. OpenAI-schema extras (token ids,base64,dimensions) run for OpenAI and Foundry ids; Titan/Bedrock ids run the string/string-array contract plus token-id/base64 rejection.NEXUS_COMPAT_ANTHROPIC_MODEL: optional Anthropic chat pin for the Anthropic slot and the native Messages slice. SetNEXUS_COMPAT_ENABLE_ANTHROPIC=0to omit native Anthropic files; OpenAI-compat Anthropic chat still runs when the catalog listsanthropic/rows.NEXUS_COMPAT_ANTHROPIC_NATIVE_MODEL: optional native Messages pin. Default is the unprefixed cheapest Anthropic chat id.NEXUS_COMPAT_IMAGE_MODEL: optional OpenAI image-generation pin for the OpenAI slot.NEXUS_COMPAT_IMAGE_EDIT_MODEL: optional OpenAI image-edit pin for the OpenAI slot.gpt-image-1-miniis not selected even when catalogued as edits, because OpenAIimages/editsrejects that id.NEXUS_COMPAT_IMAGE_VARIATION_MODEL: optional OpenAI image-variation pin for the OpenAI slot.NEXUS_COMPAT_REPORT_PATH: optional JSON report path for targeted certification runsOPENAI_API_KEY: required only for direct OpenAI comparison tests (including image token usage parity)OPENAI_COMPAT_MODEL: optional direct OpenAI chat id; defaults to the unprefixed Nexus chat idOPENAI_COMPAT_EMBEDDING_MODEL: optional direct OpenAI embedding id; defaults to the unprefixed Nexus embedding idOPENAI_COMPAT_IMAGE_MODEL: optional direct OpenAI image id; defaults to the unprefixed Nexus image idNEXUS_COMPAT_ENABLE_TRACING: set to1to collect the native OTLP trace-ingest module (test_trace_ingest.py)NEXUS_TRACE_INGEST_URL: trace-ingest endpoint for the trace suite, e.g.http://localhost:14458/v1/traces(a?key=parameter is used as the bearer token)NEXUS_TRACE_INGEST_KEY: trace ingest key when not embedded inNEXUS_TRACE_INGEST_URLNEXUS_TRACE_QUERY_TOKEN: optional developer/manager token withtrace:readfor the trace read-back assertions (falls back toNEXUS_QUERY_TOKEN/NEXUS_SERVICE_TOKEN, which only carryquery:readand cause the read-back to skip)
The direct OpenAI comparison tests are A/B shape checks. They send the same SDK call to OpenAI and to Nexus, then verify that both responses satisfy the same high-level OpenAI object contract.
Running The Anthropic Certification Slice
Section titled “Running The Anthropic Certification Slice”The Anthropic slice is a targeted provider-adapter certification for behavior implemented in the gateway today.
It uses the official Python openai SDK against the Nexus OpenAI-compatible base URL, while selecting the cheapest Anthropic-backed model currently in the registry. The default just test-compat run includes this slice whenever GET /v1/models lists an anthropic/ row.
From nexus/:
just test-compat-anthropicFrom test-suite/compat/python:
just test-anthropicTo write a machine-readable report:
NEXUS_COMPAT_REPORT_PATH=test-suite/compat/reports/anthropic-certification.json \ just test-compat-anthropicExpected provider coverage:
pass: Anthropic chat completions, streaming chat completions, tool-call translation, usage shape, terminal finish reasons, and tenant-visible model listing.unsupported: Anthropic/v1/responses,/v1/embeddings, and/v1/images/generations.- Provider-independent Nexus artifact coverage remains in the files/vector-stores suite and is not counted as Anthropic adapter coverage.
Running The Native Anthropic Messages Certification Slice
Section titled “Running The Native Anthropic Messages Certification Slice”The native slice certifies the /anthropic/v1/messages edge with the official Python anthropic SDK (pinned in pyproject.toml and spec/anthropic-sdk-provenance.json).
From nexus/:
just test-compat-anthropic-nativeTypeScript coverage with @anthropic-ai/sdk:
just test-node-anthropic-nativeClaude Code launch configuration, error-parity matrix, and the manual session checklist live under claude-code/.
To write a machine-readable report:
NEXUS_COMPAT_REPORT_PATH=test-suite/compat/reports/anthropic-native-certification.json \ NEXUS_COMPAT_REPORT_SUITE=anthropic-native-certification \ just test-compat-anthropic-nativeExpected native coverage:
pass: non-streaming and streaming messages, tool loops,count_tokens, bearer andx-api-keyauth, error envelopes (invalid key, unknown model, upstream 429/529), request-id header, unknown-route 404.live-only(requiresANTHROPIC_API_KEY): extended thinking replay, prompt caching, beta header forwarding, vision.NEXUS_COMPAT_ENABLE_THINKING=1: run extended-thinking certification cases against a stack that supports them.NEXUS_COMPAT_ENABLE_CACHING=1: run prompt-caching certification cases when cache token usage is observable.NEXUS_COMPAT_MOCK_MODEL: defaults tonxmock-tiny-fastfor upstream 429/529 error-path tests (skipped when the model is absent).
Session Analytics
Section titled “Session Analytics”tests/test_sessions_analytics.py certifies that the session-correlation headers a client sends on a request flow through the ingest pipeline into ClickHouse and become readable through the query API.
The tests send chat completions tagged with nexus-session-id (plus optional nexus-session-path and nexus-session-name), then poll GET /api/sessions and GET /api/sessions/{id}/timeline until the rows are indexed.
These tests run as part of just test-compat. They require:
NEXUS_QUERY_TOKENorNEXUS_SERVICE_TOKEN: query API auth (gateway API keys cannot read the query API).- A healthy ingest pipeline; set
NEXUS_COMPAT_REQUIRE_INGEST=1to fail instead of skip when ingest is unhealthy.
Native OTLP Trace Ingest
Section titled “Native OTLP Trace Ingest”tests/test_trace_ingest.py certifies the native tenant trace pipeline end to end: an OpenTelemetry protobuf export posted to the trace-ingest edge is normalized, indexed into ClickHouse, and read back through the query API as a trace tree and a per-session trace summary. The tool-calling scenario links an LLM and a TOOL span to a real gateway request via the nexus.request_id attribute.
It is gated and opt-in (it needs the OpenTelemetry protobuf dependency). From nexus/:
just test-compat-tracingEnvironment:
NEXUS_COMPAT_ENABLE_TRACING=1: collect the trace-ingest module (set automatically by thejusttarget).NEXUS_TRACE_INGEST_URL: trace-ingest endpoint, e.g.http://localhost:14458/v1/traces. A?key=parameter is accepted and used as the bearer token.NEXUS_TRACE_INGEST_KEY: trace ingest key when not embedded in the URL.NEXUS_TRACE_QUERY_TOKEN: a developer/manager token with thetrace:readscope. Trace reads requiretrace:read; the internal service token only carriesquery:read, so the read-back assertions skip cleanly without this token. The OTLP write path is always certified.
Full Gateway Certification
Section titled “Full Gateway Certification”To run the complete BYOK certification against a live stack in one command from nexus/:
just test-gateway-certIt runs, in order: just status, just test-compat, just test-compat-agentic, just test-compat-tracing, just test-compat-anthropic, just test-compat-anthropic-native, and just test-node-anthropic-native. It defaults NEXUS_COMPAT_AGENTIC_VECTOR_STORE_ID to the first id in NEXUS_VECTOR_STORE_IDS for the agentic file_search scenario.
Spec Refresh
Section titled “Spec Refresh”Refresh spec/openapi.yaml from the official source:
curl -fsSL https://raw.githubusercontent.com/openai/openai-openapi/refs/heads/manual_spec/openapi.yaml \ -o test-suite/compat/spec/openapi.yamlshasum -a 256 test-suite/compat/spec/openapi.yamlAfter refreshing, update spec/provenance.json with the source, retrieval time, and checksum.
