// Provider-wire compat for "xai"; regenerated from the frozen census using deployment contract selectors.

provider "xai" {
	default-model "grok-4.6"
	env "XAI_API_KEY"
	kind-apis {
		image "openai-images"
		tts "xai-tts"
	}
	web-search "xai"
	// api.x.ai rejects a body over 50 MiB and counts images only against the
	// context window; 60 images at the 500 KiB resize target stay near 41 MB.
	image-count-budget 60

	seed api="xai-tts" base-url="https://api.x.ai/v1" bundle="always" {
		model "grok-tts" name="Grok TTS" {
			reasoning #false
			input "text"
			cost input=0 output=0 cache-read=0 cache-write=0
			limits
			supports-tools #false
		}
	}

	models "grok-imagine-image" {
		kind "image"
	}
	models "grok-tts" {
		kind "tts"
	}

	// Replaces the provider-keyed prompt-cache session-header baseline.
	prompt-cache-session-header "x-grok-conv-id"
	// xAI's function-calling validator 400s on leftover root anyOf/oneOf tool
	// schemas; replaces the provider check in the OpenAI request builders.
	reject-root-object-union #true
	class "xai" {
		family "grok" {
			// Paid xAI routes through /v1/responses like SuperGrok. Encrypted
			// reasoning is requested and replayed across
			// turns, api.x.ai rejects `reasoning.summary`, `minimal` clamps to
			// `low`, and root-union tool schemas are flattened for the xAI
			// function-calling validator.
			filter-reasoning-history #false
			include-encrypted-reasoning #true
			reasoning-effort-map {
				minimal "low"
				xhigh "high"
				max "high"
			}
			supports-reasoning-summary #false
			thinking-mode "effort"
		}
	}
	// Dormant until a catalog snapshot ships grok-4.7; xhigh is native there.
	// The effort-capable allowlist accepts the wire reasoning.effort dial;
	// xhigh-capable SKUs (4.6, 4.7, multi-agent) keep xhigh unmapped.
	models "grok-3-mini*" "grok-4.20-multi-agent*" "grok-4.3*" "grok-4.5*" "grok-4.6*" "grok-4.7*" {
		supports-reasoning-effort #true
		omit-reasoning-effort #false
	}
	models "grok-4.20-multi-agent*" "grok-4.6*" "grok-4.7*" priority=1 {
		reasoning-effort-map {
			minimal "low"
		}
	}
	// residue: no-dial Responses rows (reasoning-suffixed SKUs, grok-build,
	// grok-code-fast, composer) 400 when `reasoning.effort` is present.
	models "*reasoning" "grok-build*" "grok-code-fast*" "*composer*" {
		omit-reasoning-effort #true
		supports-reasoning-effort #false
	}
	// residue: multi-agent Responses SKUs keep the native effort dial.
	// residue: taxonomy ranks and exact globs do not isolate these models.
	models "grok-4.20-0309-reasoning" "grok-4.20-beta-latest-reasoning" {
		thinking-requires-effort #true
	}
}
