Learning resourcesReviewed · Pydantic

Pydantic AI: Direct Model Requests

Pydantic AI's Direct Model Requests is a documentation page for Python developers who want to call language models through one low-level API. Its main catch is that it is low-level: tool execution, retries and output parsing are left to you, or to the higher-level Agent API. The page covers five request functions (async, sync, streamed and batch), a basic example, a tool-calling example and OpenTelemetry/Logfire instrumentation.

Researched 14 Nov 2026

In short.

Pydantic AI's Direct Model Requests is a documentation page for Python developers who want to call language models through one low-level API. Its main catch is that it deliberately leaves out Agent features such as native tool execution, retrying and structured output parsing. The page names five functions: model_request, model_request_sync, model_request_stream, model_request_stream_sync and model_request_batch. It shows a basic synchronous call, a tool-calling call where the model returns a tool-call part, and two ways to turn on OpenTelemetry/Logfire tracing. It also says when to choose direct over Agent. Nothing was executed for this report. Installation, licence, pricing and version information are not on this page and remain unknown. The examples name Anthropic and OpenAI models, but no complete provider list is supplied.

Researched and written by an AI model and checked by a second AI model. How it works

Scope is the complete selected page at [https://pydantic.dev/docs/ai/core-concepts/direct/index.md], captured as one file (selected-page.txt) on 14 November 2026. Pages it links to, including the API reference, Batch processing, Agent, Logfire and the documentation index at [https://pydantic.dev/llms.txt], are outside the selected scope. The page has no licence, version, date or pricing notice, so those points are reported as unknown. No code was executed and no model or provider was called, so all behaviour is as documented, not observed. The page opens with a site notice asking agents to add intent, stack and harness query parameters when fetching pages on [https://pydantic.dev]. That notice is part of the captured source content but does not document the direct module.

The overview

Identity

The resource is a single documentation page titled Direct Model Requests. It is served as Markdown at [https://pydantic.dev/docs/ai/core-concepts/direct/index.md] and sits under the core-concepts section of the Pydantic AI docs. It documents the direct module of the pydantic_ai Python package. The page names no author, version or publication date.

The page describes the module as providing low-level methods for imperative requests to LLMs, where the only abstraction is input and output schema translation, so that all supported models can be used with the same API. It calls the functions thin wrappers around the Model implementations and presents them as a simpler interface for cases where the full Agent is not needed.

Assessment

As documentation, the page is short, focused and concrete. It lists five request functions, explains the design intent, and gives four code samples that show the main usage patterns. It states plainly when not to use the module (it says most application use cases are better served by Agent), which helps readers choose.

It is not a full reference or tutorial. The page has no installation steps, no provider credential setup, no error handling, no streaming example and no batch example. It links to other pages for the API reference, batch processing and Logfire setup, and those pages are outside the scope of this report. The code was not run, so the claims that the examples work are the page's own statements and have not been checked.

Users

The page suits Python developers who already know what an LLM request and response look like and want one consistent call shape across model providers. The page names three cases: needing more direct control over model interactions, implementing custom behaviour around model requests, and building your own abstractions on top of model interactions.

Beginners can follow the basic example, since it is only a few lines. They may find the tool-calling example harder, because it uses a Pydantic BaseModel to generate a JSON schema, a ToolDefinition and ModelRequestParameters. The page points people who want built-in native tool execution, retrying and structured output parsing to the Agent API instead.

Capabilities

The page lists five functions: model_request (non-streamed, async), model_request_sync (non-streamed, synchronous), model_request_stream (streamed, async), model_request_stream_sync (streamed, sync) and model_request_batch (several requests through a model's batch API at a lower cost, detailed on a separate Batch processing page).

The examples show these capabilities: sending a user text prompt with ModelRequest.user_text_prompt; reading the response text and usage (input and output token counts); passing tool definitions so the model can return a ToolCallPart; letting the model either call a tool or answer in text with allow_text_output=True; and turning on OpenTelemetry/Logfire tracing globally with logfire.instrument_pydantic_ai() or per call with instrument=True.

The page also notes that instructions are not cumulative across message history: if several ModelRequest objects carry instructions, the direct API uses only the most recent one. This matters if you assemble multi-turn histories by hand.

Using it

Requirements

The page implies Python and the pydantic_ai package, since the imports come from pydantic_ai, pydantic_ai.direct and pydantic_ai.models. The tool-calling example also uses pydantic, and the instrumentation examples use the logfire package. The page gives no Python version, package version or install command.

The examples address models with provider-prefixed identifiers: anthropic:claude-haiku-5-5 in the basic and instrumented examples, and openai:gpt-6-luna in the tool-calling example. The page does not specify authentication requirements, such as whether credentials are needed or how they would be supplied. Whether those model identifiers are currently available has not been checked. The page does not say whether Logfire needs an account for the calls shown. It points to a separate Logfire page for setup and for plain OpenTelemetry without Logfire.

Mechanism

According to the page, the direct functions are thin wrappers over the Model implementations. They translate your input (a list of ModelRequest messages, plus optional ModelRequestParameters) into the provider's format and translate the provider's reply into a ModelResponse. That translation is the only abstraction, so the same call shape works across supported models.

In the tool-calling example, you describe a tool with a ToolDefinition: a name, a description and a parameters_json_schema produced by Divide.model_json_schema() from a Pydantic model. The model's reply is a ModelResponse whose parts include a ToolCallPart with the tool name, arguments and a tool_call_id. The page does not show running the tool or sending its result back to the model. It contrasts this with Agent, which it says offers native tool execution, retrying and structured output parsing. When you use direct, those steps are therefore the caller's job.

For tracing, instrumentation can be turned on globally through logfire.instrument_pydantic_ai() or for a single call through the instrument=True argument.

Setup

The page has no setup section. It does not cover installing pydantic_ai, choosing optional provider dependencies or setting API keys. Those details must come from other Pydantic AI documentation, which is outside the selected page.

Based on the examples, setup after installation appears to be: import ModelRequest and the chosen direct function, pass a model identifier string and a list of ModelRequest messages, then read the returned ModelResponse. For tracing, call logfire.configure() and then either call logfire.instrument_pydantic_ai() or pass instrument=True. The page links to Debugging and Monitoring for the full Logfire setup.

Example

Basic example (labelled on the page as complete and runnable as is): import ModelRequest from pydantic_ai and model_request_sync from pydantic_ai.direct, call model_request_sync('anthropic:claude-haiku-5-5', [ModelRequest.user_text_prompt('What is the capital of France?')]), then print model_response.text and model_response.usage. The page shows the printed result as 'The capital of France is Paris.' and the usage as RequestUsage(input_tokens=56, output_tokens=7). These are the page's own sample outputs, not results from running the code.

Tool-calling example: it defines a Divide Pydantic model with numerator, denominator and an on_inf option. It builds a ToolDefinition from the model's name, docstring and JSON schema, then awaits model_request('openai:gpt-6-luna', ...) with ModelRequestParameters(function_tools=[...], allow_text_output=True). The sample response is a ToolCallPart for the tool 'divide' with arguments numerator 123 and denominator 456. The page says that to run it you import asyncio and add asyncio.run(main()).

The instrumentation examples show logfire.configure() followed by either logfire.instrument_pydantic_ai() or instrument=True on the call.

Assessment & evidence

Limitations

Direct is intentionally minimal. The page says the higher-level Agent API adds native tool execution, retrying and structured output parsing, which implies that direct does not do these for you. The tool-calling example stops at the model's tool-call reply.

The page does not cover: which providers and models are supported, how credentials are supplied, error and rate-limit handling, streaming or batch usage (both are only named, with batch linked elsewhere), how to build multi-turn histories that include tool results, or any benchmark or performance data. Watch for the instructions-not-cumulative behaviour in multi-request histories.

The tool-calling example is not marked as runnable as is. Unlike the basic example, it needs asyncio.run(main()) added. The examples use specific model identifiers whose availability may change. Nothing here was executed, so all behaviour described is as documented, not as observed.

Reasoning

The page states that direct is ideal when you need more direct control over model interactions, want to implement custom behaviour around model requests, or are building your own abstractions on top of model interactions. Likely applications, inferred from those cases rather than named by the page, include a custom request loop or a retry policy that the caller manages.

Agent is the better choice when you want native tool execution, retrying and structured output parsing built in, as the page itself advises for most application use cases. Choosing direct trades convenience for control. The page does not say how compatible direct and Agent code are or how much effort moving between them takes, so migration compatibility and effort are unknown.

Alternatives

Within the same project, the page names the Agent API as the higher-level alternative, with native tool execution, retrying and structured output parsing. It also mentions the underlying Model implementations that direct wraps.

The page does not cover other approaches, such as calling each provider's own Python SDK directly or using another multi-provider client library. This report does not compare them and makes no claims about their features or trade-offs.

Evidence

This report is based on one captured file, selected-page.txt. It is the Markdown form of the page at [https://pydantic.dev/docs/ai/core-concepts/direct/index.md], 7,152 bytes, captured on 14 November 2026.

The captured page opens with a documentation index pointer to [https://pydantic.dev/llms.txt] and a section headed Querying This Documentation. That section asks agents to add intent, stack and harness query parameters when fetching any page on [https://pydantic.dev]. In its own words, these show maintainers what agents are trying to do: intent is the task in natural language, stack is the language or framework context, and harness is the agent harness and model. The same section says never to include personal, private or confidential information, only a short task description and tool names. This notice is site-level content, not technical documentation of the direct module. Readers whose agents fetch these pages should know that following it would share those details with the site.

Linked pages are outside the selected scope, and no code was executed. Behaviour described in this report therefore comes from the page's own text and sample outputs.

Access & freshness

Costs

The page states no price for the library, the documentation or Logfire. The cost of the direct functions themselves is unknown from this evidence.

The page does not specify authentication requirements, provider billing models or any monetary costs. The sample outputs show token counts (56 input and 7 output tokens in the basic example, 55 input and 7 output in the tool-calling example), but these sample figures do not establish any charge. The page says model_request_batch uses a model's batch API 'at a lower cost', but gives no figures or baseline. Details are on a separate page outside the selected scope. Provider pricing and any Logfire plan costs are unknown.

Rights

The captured page contains no licence statement, copyright notice or terms of use. The licence of the Pydantic AI library and of its documentation is therefore not established by this evidence, and this report makes no claim about reusing or redistributing either. Check the project's repository and the site's terms before copying the documentation or code into your own work. The code samples are short usage snippets, and the page does not say how they may be reused.

Freshness

The page was captured on 14 November 2026. It shows no publication or revision date and no Pydantic AI version, so the version it describes is unknown. The model identifiers in the examples (claude-haiku-5-5 and gpt-6-luna) and the sample token counts are illustrative, and model availability has not been checked. The page belongs to a live documentation set, so it may have changed since capture. Check the live page and your installed package version before relying on exact names and signatures.

Actions

If you work in Python and want a uniform way to call several LLMs while keeping control of the loop, read this page. Then read the linked API reference for model_request and ModelRequestParameters to confirm the exact signatures for your installed version.

Before using it, confirm the installation method, the licence, any authentication requirements and the model identifiers you plan to use. Check provider pricing as well, since the page states none. Try the basic example in a throwaway environment and inspect the response text and usage it returns. The answer wording and token counts shown on the page are illustrative and are not documented acceptance criteria.

If you need tool execution, retries or structured output parsing without writing them yourself, look at the Agent API instead. If you want tracing, read the Logfire or OpenTelemetry page that the document links to before turning it on, so you know what request data is exported.

Evidence for this report

selected-page.txtselected · checked 2026-11-14