Documentation
¶
Overview ¶
Package contracttest contains deterministic provider-package HTTP contracts. It is internal test infrastructure, not a public runtime API.
Index ¶
- func Anthropic(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)
- func AnthropicBearer(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)
- func NoDefaultOpenCodeAttribution(t *testing.T, provider llm.Provider, key auth.APIKey, header string, ...)
- func OpenAI(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)
- func OpenAIWithHeader(t *testing.T, provider llm.Provider, key auth.APIKey, header string, ...)
- func Responses(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)
- func ResponsesWithHeader(t *testing.T, provider llm.Provider, key auth.APIKey, header string, ...)
- func SessionHeader(t *testing.T, provider llm.Provider, key auth.APIKey, header string, ...)
- func SessionIDNotForwarded(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)
- type Constructor
- type OptionConstructor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Anthropic ¶
Anthropic verifies native Messages JSON/SSE, x-api-key authentication, usage, and finish normalization for a provider that exposes Anthropic semantics.
func AnthropicBearer ¶
AnthropicBearer verifies native Messages JSON/SSE for gateways that expose Anthropic semantics but deliberately authenticate the whole gateway with a bearer token (for example Cloudflare AI Gateway and Vercel AI Gateway).
func NoDefaultOpenCodeAttribution ¶
func NoDefaultOpenCodeAttribution(t *testing.T, provider llm.Provider, key auth.APIKey, header string, construct OptionConstructor)
NoDefaultOpenCodeAttribution verifies that a gateway does not silently send OpenCode branding headers, while preserving an explicit caller override.
func OpenAI ¶
OpenAI verifies the common JSON/SSE, auth, usage, finish, and route contract for a provider using the OpenAI Chat Completions dialect.
func OpenAIWithHeader ¶
func OpenAIWithHeader(t *testing.T, provider llm.Provider, key auth.APIKey, header string, construct Constructor)
OpenAIWithHeader is the same contract for providers such as Azure that use a documented API-key header instead of Authorization: Bearer.
func Responses ¶
Responses verifies the common OpenAI Responses JSON/SSE, bearer auth, usage, tool/finish normalization, and /responses route contract.
func ResponsesWithHeader ¶
func ResponsesWithHeader(t *testing.T, provider llm.Provider, key auth.APIKey, header string, construct Constructor)
ResponsesWithHeader verifies the Responses dialect for providers such as Azure that use a documented API-key header instead of Authorization: Bearer.
func SessionHeader ¶ added in v0.15.0
func SessionHeader(t *testing.T, provider llm.Provider, key auth.APIKey, header string, construct OptionConstructor)
SessionHeader verifies a provider that forwards inference.Request.SessionID in header, on every request format:
- absent when the request carries no SessionID, so a caller that predates the field sends exactly what it sent before;
- the SessionID verbatim, as the header's only value, when it does (on Invoke for every format, and on Stream for the OpenAI format);
- an explicit non-empty WithHeader value wins over the per-request one;
- an unsendable SessionID is refused locally with *inference.InvalidSessionIDError and no request reaches the provider.
func SessionIDNotForwarded ¶ added in v0.15.0
func SessionIDNotForwarded(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)
SessionIDNotForwarded verifies a provider that documents no session header sends inference.Request.SessionID nowhere in its request headers: the identity is caller data, and a provider that has not said it reads it must not receive it.