instructor_dart library

Typed, validated structured outputs from LLMs.

Define the shape of the data you want with Schema, call Instructor.extract, and get back a validated Dart object. Responses that do not match the schema are sent back to the model with the validation errors, and it gets another try.

Classes

AnthropicAdapter
Adapter for the Anthropic Messages API.
BooleanSchema
Schema for boolean values. See Schema.boolean.
EnumSchema
Schema for a string restricted to a fixed set of values. See Schema.enumeration.
ExtractionAttempt
One failed attempt inside extract/extractRaw.
GeminiAdapter
Adapter for the Gemini API's generateContent method.
Instructor
Extracts typed, schema-validated data from an LLM.
IntegerSchema
Schema for integer values. See Schema.integer.
ListSchema
Schema for lists. See Schema.list.
LlmAdapter
Bridge between LlmRequest and one provider's HTTP API.
LlmRequest
A provider-agnostic completion request.
LlmResponse
A provider-agnostic completion response.
Message
A single chat message sent to the model.
NumberSchema
Schema for numeric values (integer or double). See Schema.number.
ObjectSchema
Schema for objects with named properties. See Schema.object.
OpenAIAdapter
Adapter for the OpenAI Chat Completions API and compatible servers (Ollama, LM Studio, vLLM, OpenRouter, and others exposing /v1).
Schema
Declarative description of the shape of data expected from a model.
SchemaViolation
A single problem found while validating a value against a Schema.
StringSchema
Schema for string values. See Schema.string.

Enums

MessageRole
Role of a chat message.

Exceptions / Errors

AdapterException
The error type every adapter reports, so a caller can write a single on AdapterException catch (e) around a complete call.
ExtractionException
Thrown when the model failed to produce schema-conforming data within the configured number of attempts. Carries every attempt so failures are debuggable instead of opaque.