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.
OllamaApi is a PHP backed string enum used to select which Ollama API surface handles text generation requests. It is stored on OllamaOptions and can be supplied as a string or enum case anywhere the SDK accepts an api configuration key.
Namespace
Cases
Default. Routes generation requests to the
/chat/completions endpoint on the OpenAI-compatible API. Supports the full feature set: streaming, tool calls, vision inputs, reasoning effort control, and structured output constraints.Routes generation requests to the
/responses endpoint. Supports streaming and tool calls. Does not support reasoning effort controls or structured output constraints.Feature matrix
| Feature | ChatCompletions | Responses |
|---|---|---|
| Streaming | ✅ | ✅ |
| Tool calls | ✅ | ✅ |
| Vision inputs | ✅ | — |
| Reasoning effort | ✅ | — |
| Structured output | ✅ | — |
Static Method
OllamaApi::resolve()
OllamaApi case. Used internally by OllamaOptions::fromArray() to normalise the api config key, but can also be called directly.
Resolution behaviour:
OllamaApiinstance — returned as-is, no conversion performed.nullor empty string — returnsOllamaApi::ChatCompletions(the default).- Non-empty string — lowercased and trimmed, then matched case-insensitively against each case’s
.value. Matching is exact after normalisation. - Any other type, or an unrecognised string — throws
AiSdk\Exceptions\InvalidArgumentExceptionwith the message'Invalid Ollama API surface. Expected chat_completions or responses.'
Usage in Configuration
Pass a string or enum case as theapi key when constructing the provider:
OllamaApi::resolve() inside OllamaOptions::fromArray().
Usage in Per-Request Override
Theapi surface can also be switched on a per-request basis using providerOptions(), without changing the provider-level default:
ChatCompletions but specific calls benefit from the Responses endpoint, or vice versa.
See API Endpoints for a full comparison of which features are available on each API surface, including how provider options are merged at the request level.
