Help us shape the future of Go! Take the 2026 Go Developer Survey

contracttest

package
v0.16.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package contracttest contains deterministic provider-package HTTP contracts. It is internal test infrastructure, not a public runtime API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Anthropic

func Anthropic(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)

Anthropic verifies native Messages JSON/SSE, x-api-key authentication, usage, and finish normalization for a provider that exposes Anthropic semantics.

func AnthropicBearer

func AnthropicBearer(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)

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

func OpenAI(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)

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

func Responses(t *testing.T, provider llm.Provider, key auth.APIKey, construct Constructor)

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.

Types

type Constructor

type Constructor func(model.Model, auth.APIKey) (inference.Client, error)

type OptionConstructor

type OptionConstructor func(model.Model, auth.APIKey, ...simple.Option) (inference.Client, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL