Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/phpaisdk/ollama/llms.txt

Use this file to discover all available pages before exploring further.

Ollama exposes an experimental OpenAI-compatible /images/generations endpoint. The aisdk/ollama provider supports this endpoint through the standard Generate::image() interface, allowing you to generate images with any image model installed on your Ollama server.
Image generation is experimental in Ollama. Availability and behavior depend entirely on the installed model and the version of Ollama running on your server. Use this feature with the expectation that it may change.

Basic image generation

use AiSdk\Generate;
use AiSdk\Ollama;

$image = Generate::image('A small robot')
    ->model(Ollama::model('your-image-model'))
    ->size('1024x1024')
    ->run();

$bytes = $image->output->bytes();

Fields sent to Ollama

The adapter deliberately restricts the request body to only the fields Ollama’s experimental endpoint documents. Regardless of what you pass to the fluent builder, only these four fields are forwarded:
FieldDescription
modelThe model ID passed to Ollama::model().
promptThe text prompt passed to Generate::image().
sizeThe requested image dimensions (e.g. '1024x1024').
response_formatAlways set to b64_json by the adapter.
All other fields — including n (count), seed, quality, style, user, and any raw provider options — are silently dropped before the request is sent.
Provider options and raw overrides are not forwarded for image requests. Only the four documented fields above are included in the request body.

Default size

If you do not call ->size(), the adapter defaults to '1024x1024'. Ollama requires a size field to be present, so the adapter always ensures it is set:
// size defaults to '1024x1024' — both calls are equivalent
Generate::image('A small robot')->model(Ollama::model('your-image-model'))->run();
Generate::image('A small robot')->model(Ollama::model('your-image-model'))->size('1024x1024')->run();

Speech generation

Ollama does not expose an OpenAI-compatible speech endpoint, so Generate::speech() is intentionally not implemented in this provider. Attempting to use a speech model through the Ollama adapter is not supported.

Build docs developers (and LLMs) love