Download the PHP package unlikelysource/simplified-openrouter-php-sdk without Composer

On this page you can find all versions of the php package unlikelysource/simplified-openrouter-php-sdk. 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 simplified-openrouter-php-sdk

simplified_openrouter_php_sdk

An unofficial PHP SDK for the OpenRouter.ai API, modeled after the official Python SDK. This is a hand-written, idiomatic PHP client, not a generated 1:1 port — covering the core of the OpenRouter API:

The Python SDK is auto-generated from OpenRouter's OpenAPI spec and covers ~90 endpoint groups (TTS/STT, video generation, OAuth, workspaces, BYOK, datasets, guardrails, analytics, and more). This simplified PHP SDK, by design, covers only the subset most developers need. The architecture (a Transportclass plus one resource class per endpoint group) makes it straightforward to add more resources later if you need them. Contributions welcome!

This SDK leverages the Guzzle HTTP client, and produces PSR-7 compliant requests and responses. IMPORTANT: this is an Alpha release. If you need something more stable and production-ready, consider using eatzy/openrouter-php-sdk instead.

Requirements

Installation

Quick start

Streaming

createStreamed() returns a ChatCompletionStream, an IteratorAggregate that lazily parses the API's text/event-stream response and yields one ChatCompletionChunk per server-sent event, stopping automatically at the [DONE] sentinel.

Request parameters

chat->create() / chat->createStreamed() accept the request body as a plain associative array, matching the OpenRouter Chat Completions API directly (model, messages, temperature, max_tokens, tools, tool_choice, provider, reasoning, response_format, etc.) — nothing is hidden behind a rigid DTO, so any parameter the API supports can be passed through as-is. messages entries may be plain arrays or OpenRouter\DTO\ChatMessage instances (ChatMessage::system(), ::user(), ::assistant(), ::tool()).

Resources

See examples/ for complete runnable scripts.

Configuration

You can also inject your own Guzzle client (e.g. with custom middleware or a mock handler for testing) via the httpClient constructor argument.

Error handling

Requests that receive an HTTP error status throw a subclass of OpenRouter\Exceptions\ApiException, mapped by status code (BadRequestException, UnauthorizedException, PaymentRequiredException, ForbiddenException, NotFoundException, TooManyRequestsException, InternalServerException, etc.):

Connection-level failures (DNS, timeouts, refused connections) that persist after retries are exhausted throw OpenRouter\Exceptions\TransportException instead.

5xx responses are retried automatically with exponential backoff (defaults: up to 4 attempts, starting at 500ms, capped at 60s, 1.5x multiplier) before an exception is raised.

Development

License

MIT. Not affiliated with or endorsed by OpenRouter.


All versions of simplified-openrouter-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
guzzlehttp/guzzle Version ^7.5
psr/http-message Version ^1.1 || ^2.0
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 unlikelysource/simplified-openrouter-php-sdk contains the following files

Loading the files please wait ...