Skip to content

Releases: cheinisch/OpenRouter-php-Client

Update README and CHANGELOG for v0.3

22 Apr 06:46

Choose a tag to compare

What's Changed

Breaking Changes

  • chat() now accepts an optional 4th parameter $options [] — existing calls with 1–3 arguments are fully backwards compatible
  • chatEx() returns an array instead of string — use chat() if you need a plain string response

New Features

  • chatEx() — extended chat completion returning a full result array:
    id, content, finish_reason, tool_calls, reasoning, usage
  • stream() — SSE streaming support via callback fn(string $delta, bool $done): void
  • structuredChat() — JSON Schema validated responses, returns decoded PHP array directly
  • getGenerationStats() — fetch token counts and cost asynchronously via /api/v1/generation
  • Tool Callingtools, tool_choice, parallel_tool_calls
  • Structured Outputsresponse_format with json_object and json_schema modes
  • Pluginsweb, file-parser, response-healing, context-compression
  • Provider Routingprovider object with sort, data_collection, allow, ignore
  • Reasoning Modelsreasoning parameter with effort levels for Claude 3.7+, o1/o3
  • Observabilitysession_id tracking via x-session-id header
  • Output Modalitiesmodalities parameter (text, audio, image)

Improvements

  • chat() is now a thin wrapper around chatEx() — no duplicated logic
  • Replaced deprecated max_tokens with max_completion_tokens throughout
  • Error handling now parses structured API error body (error.message, error.code)
  • All runtime exception messages translated to English

Installation

composer require cheinisch/openrouter-php-client

Quick Example

// Simple – unchanged from previous versions
$client = new OpenRouterClient($apiKey);
$text   = $client->chat([['role' => 'user', 'content' => 'Hello!']], 'openai/gpt-4o-mini');

// Extended – new in v0.3
$result = $client->chatEx(
    [['role' => 'user', 'content' => 'Hello!']],
    'openai/gpt-4o-mini',
    ['plugins' => [['id' => 'web']]]
);
echo $result['content'];
echo $result['usage']['total_tokens'];

Full Changelog: v0.2.2...v0.3

v0.2.2

08 Oct 08:39
32a3804

Choose a tag to compare

v0.2.2

Changes

  • Change description from german to english

v0.2.1

18 Sep 10:18

Choose a tag to compare

Update CHANGELOG.md

v0.2

18 Sep 07:16

Choose a tag to compare

v0.2.0

Changes

  • Change Namespace from OpenROuter\Client to cheinisch\OpenRouterClient
  • Change Client::OpenRouterChat to OpenRouterClient::OpenRouterChat

v0.1.1

04 Sep 21:53
c54f8af

Choose a tag to compare

Full Changelog: v0.1.0...v0.1.1

v0.1.0

04 Sep 21:49
4b3d25f

Choose a tag to compare

Full Changelog: v0.0.0.5...v0.1.0

v0.0.0.5

04 Sep 19:33
d0299ed

Choose a tag to compare

Update README.md

v0.0.0.4

04 Sep 19:17
84d7ddb

Choose a tag to compare

Aktualisieren von CHANGELOG.md

v0.0.0.3

04 Sep 18:27

Choose a tag to compare

Update Client.php

v0.0.0.2: Add OpenRouterChat convenience method and README example

04 Sep 17:31

Choose a tag to compare

Introduces the OpenRouterChat static method to simplify chat API usage by requiring only API key, model, and prompt. Updates README with usage instructions and an example.