Search by

adachsoft / ai-integration-openrouter

OpenRouter integration for adachsoft/ai-integration.

Maintainers

Package info

gitlab.com/a.adach/ai-integration-openrouter

Issues

pkg:composer/adachsoft/ai-integration-openrouter

Transparency log

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

v0.1.0 2026-08-28 05:31 UTC

This package is not auto-updated.

Last update: 2026-08-29 01:49:49 UTC


README

This package integrates OpenRouter with the ToolCallingChatSpiInterface from adachsoft/ai-integration through OpenRouter's OpenAI-compatible API.

Requirements

  • PHP 8.4 or newer
  • adachsoft/ai-integration 0.8 or newer

Installation

composer require adachsoft/ai-integration-openrouter

Usage

Create an OpenRouterConfigVo and pass it to OpenRouterToolCallingChatSpiFactory:

use AdachSoft\AiIntegrationOpenRouter\Config\OpenRouterConfigVo;
use AdachSoft\AiIntegrationOpenRouter\OpenRouterToolCallingChatSpiFactory;

$config = new OpenRouterConfigVo(apiKey: 'your-openrouter-api-key');
$spi = new OpenRouterToolCallingChatSpiFactory($config)->create();

The factory returns a ToolCallingChatSpiInterface implementation. The default endpoint is:

https://openrouter.ai/api/v1/chat/completions

The model is supplied on each SPI request. It is not stored in the provider configuration.

HTTP status 402 is classified as exhausted provider resources and is exposed by the core integration as ResourceExhaustedSpiException.

Configuration

Copy .env.example to .env for production tests and set the API key:

OPENROUTER_API_KEY=...

The package does not read or configure a model from the environment.

Tests

Run unit tests without external network requests:

composer test

Run the production tool-calling test against OpenRouter:

composer test:production

The production test performs real, potentially billable requests using the openai/gpt-4.1-mini model.