Skip to main content
The Model Inference API enables you to run LLM inference within your data plane. This reference documents all methods, types, and interfaces available in the TypeScript SDK.

Methods

runModelInference

Submits a model inference request and returns a job that can be polled for results.
Parameters: Returns: Promise<ModelInferenceRunJob> - A job object that can be polled for completion. Example:

Types

InferenceModel

Model identifiers supported by the Narrative model inference API.
Models flagged as forced-tool-use enforce output_format_schema via client-side validation instead of native grammar constraints, and require the top-level object schema to set additionalProperties: false. See Structured Output for details.

MessageRole

The role of a message in the conversation.

InferenceMessage

A message in the inference conversation. The content field is an ordered array of content blocks; the dominant block type is text. Agent-loop flows additionally emit tool_use (model requesting a tool call) and tool_result (response) blocks — see ContentBlock below.
Example:
The legacy { role, text: string } shape is still accepted on requests for backwards compatibility — the API auto-canonicalizes it into a single text content block. Responses always emit the content-block shape. Migrate to the new shape on next edit.

InferenceConfig

Configuration parameters for the inference request.
Example:

ModelInferenceRunRequest

The complete request body for running a model inference job.

InferenceUsage

Token usage metrics from the inference response.

ModelInferenceRunResult

The result from a completed model inference job.
structured_output and failed_structured_output are mutually exclusive — at most one is populated on any completed job. The inference job completes either way, so always check failed_structured_output before consuming structured_output.
Example with typed output:

ModelInferenceRunJob

The job object returned when submitting an inference request. Extends the base job type with inference-specific result typing.

Error handling

Model Inference jobs can fail for several reasons: Example error handling:

Running Model Inference

Step-by-step guide to submitting inference requests

Structured Output

Working with JSON Schema for typed responses

Tracking Jobs

Monitor inference job status

Supported Models

Available models and specifications