Download the PHP package vluzrmos/ollama without Composer

On this page you can find all versions of the php package vluzrmos/ollama. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ollama

Ollama PHP Client

PHP client for the Ollama native API and OpenAI-compatible endpoints, with support for PHP 5.6+.

This library provides:

Features

Requirements

Installation

Quick Start

Ollama Native API

OpenAI-Compatible API

Core Concepts

Model

The Model class lets you define a reusable model plus default request parameters.

Supported convenience setters include:

Message

The Message helper supports standard chat roles, tool messages, and multimodal payloads.

Available constructors:

Response Wrappers

Responses are returned as wrapper objects that implement array-style access and can also be converted back to raw arrays.

Useful helpers include:

Ollama Client

Class: Vluzrmos\Ollama\Ollama

Default base URL: http://localhost:11434

Main Operations

Text generation

Chat completions

Embeddings

Model and Runtime Management

The native Ollama client exposes the following operations:

Example:

Authentication

If your Ollama-compatible endpoint requires a Bearer token:

OpenAI-Compatible Client

Class: Vluzrmos\Ollama\OpenAI

Default base URL: http://localhost:11434/v1

Default API key: ollama

Supported Endpoints

High-Level Convenience Methods

Low-Level Request Methods

Chat Example

Text Completion Example

Embedding Example

Responses API

The OpenAI client supports the Responses API, which provides a stateful alternative to Chat Completions with built-in support for multi-turn conversations, tool calling, and structured output.

Simple Response

Multi-Turn Conversation

Use previous_response_id to chain multiple turns without manually tracking messages:

Streaming

Tool Calling

Structured Output

Retrieve, Delete and Cancel

Response Model

The ResponsesResponse wrapper provides typed access to the response fields:

Streaming

Both clients support streamed responses through a callback that receives decoded chunks.

Ollama Streaming

OpenAI Streaming

Async Requests

Async variants are available on both clients and return Guzzle promises.

Examples:

Concurrent Requests (Pool)

Use the pool() method to send multiple requests concurrently via Guzzle's Pool. Each yielded value must be a callable that returns a promise (not a promise directly).

Pool configuration options:

Option Type Description
concurrency int Maximum number of requests to send concurrently
fulfilled callable Callback invoked when a request completes. Receives ($response, $index)
rejected callable Callback invoked when a request fails. Receives ($reason, $index)

Important: Each yielded value must be a closure that returns a promise (e.g. wrapping an *Async() call), not the promise itself. Passing promises directly will throw an InvalidArgumentException.

The pool() method is available on both OpenAI and Ollama clients. You can use any async method (chatAsync(), completeAsync(), embedAsync(), etc.) inside the generator.

Vision and Images

Use Message::image() together with ImageHelper for vision-capable models.

Available helpers:

JSON Mode and Structured Output

OpenAI-compatible chat requests accept response_format options, including json_object and json_schema.

Tools and Function Calling

The library includes a complete tool system with registration, serialization, execution, and conversion of tool results back into chat messages.

Creating a Custom Tool

ToolManager

Available operations:

OpenAI-Compatible Tool Calling Flow

For dynamic values such as the current date or current time, do not include the answer itself in the system prompt or conversation context if you expect a tool call. If the model already sees that value in the prompt, it may answer directly and skip the tool. Add an explicit instruction to use the tool for time-sensitive questions and, when your OpenAI-compatible provider supports it, consider passing tool_choice for deterministic tool selection.

Built-In Tools

High-Level Chat Orchestrator

Class: Vluzrmos\Ollama\Chat\Chat

This wrapper maintains conversation history, registers tools, sends messages through a chat adapter, and automatically re-enters the model when tool calls are returned.

Main operations:

Agents

The agent layer builds on top of the clients and tool manager to provide reusable role-based assistants.

Agent

Class: Vluzrmos\Ollama\Agents\Agent

An agent has:

Agent operations:

AgentGroup

Class: Vluzrmos\Ollama\Agents\AgentGroup

An agent group uses a selector prompt to either:

Available operations:

Client Adapters

The agent system includes adapters for both client styles:

HTTP Client Configuration

Both top-level clients accept HTTP options in the constructor and expose the underlying HttpClient through getHttpClient().

Error Handling

Custom exceptions include:

Examples

The repository includes working examples for the main library features:

Custom example tools are available in:

Testing

Run the test suite with Docker:

Docker Development Environment

The included Docker image can also be used to run examples or custom commands.

Supported environment variables:

Run a custom command:

Mount your local project into the container if needed:

License

MIT

Contributing

Contributions are welcome. See CONTRIBUTING.md for project guidelines.


All versions of ollama with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
ext-curl Version *
ext-json Version *
guzzlehttp/guzzle Version ^6.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vluzrmos/ollama contains the following files

Loading the files please wait ...