import type { ContentBlock } from "../agents/types"; /** * Model identifiers supported by the Narrative model inference API. * Maps to Scala ModelInferenceRunJobInput.Model */ export type InferenceModel = "anthropic.claude-haiku-4.5" | "anthropic.claude-sonnet-4.5" | "anthropic.claude-sonnet-4.6" | "anthropic.claude-sonnet-5.0" | "anthropic.claude-sonnet-5.5" | "anthropic.claude-opus-4.5" | "anthropic.claude-opus-4.6" | "anthropic.claude-opus-4.7" | "anthropic.claude-opus-4.8" | "anthropic.claude-opus-5.0" | "anthropic.claude-opus-5.5" | "openai.gpt-oss-120b" | "openai.gpt-4.1" | "openai.o4-mini"; /** * Message role for inference requests. * Maps to Scala ModelInferenceRunJobInput.Role */ export type MessageRole = "user" | "assistant" | "system"; /** * A message in the inference conversation using the current content-block * wire shape (the same `ContentBlock` union used by the agents API). * Responses always emit this shape; new integrations should send it too. * Maps to Scala ModelInferenceRunJobInput.Message. */ export interface InferenceContentMessage { role: MessageRole; content: ContentBlock[]; } /** * A message in the inference conversation using the legacy `{role, text}` * shape. Still accepted on requests for backwards compatibility — the API * auto-canonicalizes it into a single `text` content block — but new * integrations should prefer {@link InferenceContentMessage}. * Maps to Scala ModelInferenceRunJobInput.Message (legacy decoder). */ export interface InferenceMessage { role: MessageRole; text: string; } /** * Any message shape accepted by `POST /model-inference/run`: the current * content-block shape or the legacy `{role, text}` shape. */ export type InferenceRequestMessage = InferenceContentMessage | InferenceMessage; /** * Configuration for the inference request. * Maps to Scala ModelInferenceRunJobInput.InferenceConfig */ export interface InferenceConfig { /** JSON Schema defining the expected output format */ output_format_schema: Record; /** Maximum number of tokens to generate */ max_tokens?: number; /** Sampling temperature (0-1) */ temperature?: number; /** Top-p (nucleus) sampling parameter (0-1) */ top_p?: number; /** Sequences that will stop generation */ stop_sequences?: string[]; } /** * Request body for running a model inference job. * Maps to Scala RunRequest */ export interface ModelInferenceRunRequest { /** The data plane ID to run the inference on */ data_plane_id: string; /** The model to use for inference */ model: InferenceModel; /** The conversation messages */ messages: InferenceRequestMessage[]; /** Configuration for the inference */ inference_config: InferenceConfig; /** Optional tags for the job */ tags?: string[]; } /** * Token usage metrics from the inference. */ export interface InferenceUsage { total_tokens: number; prompt_tokens: number; completion_tokens: number; } /** * Result from a model inference job. * @template T - The type of the structured output, defaults to unknown */ export interface ModelInferenceRunResult { /** Token usage metrics */ usage: InferenceUsage; /** The structured output matching the output_format_schema */ structured_output: T; }