Download the PHP package crademaker/openrouter-wrapper without Composer
On this page you can find all versions of the php package crademaker/openrouter-wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download crademaker/openrouter-wrapper
More information about crademaker/openrouter-wrapper
Files in crademaker/openrouter-wrapper
Package openrouter-wrapper
Short Description OpenRouter API wrapper as a Composer-compatible PHP package
License MIT
Homepage https://github.com/rademakeronline/openrouter
Informations about the package openrouter-wrapper
OpenRouter Composer Wrapper
Composer-compatible PHP wrapper for the OpenRouter API, built on PSR-18.
Installation
Quick Start
Usage In Existing Projects
Standard installation via Packagist:
Minimal bootstrap in an existing project:
Typical follow-up:
- register the client as a service or singleton
- inject
OPENROUTER_API_KEYthrough.env, a secret store, or CI variables - use concrete model IDs instead of routing aliases if you need reproducible behavior
Language Policy
This repository follows a simple rule for public distribution:
- public package surface is written in English
- GitHub-facing documentation is written in English
- Composer metadata is written in English
- examples and release-facing documentation are written in English
This keeps the package aligned with common GitHub, Packagist, and Composer expectations.
Example READMEs
Common use cases are documented under examples/:
- examples/README.md
- examples/chat/README.md
- examples/responses/README.md
- examples/embeddings/README.md
- examples/vision/README.md
- examples/streaming/README.md
Typed DTO API
In addition to array payloads, the package provides semantic DTOs per endpoint group under Crademaker\OpenRouter\DTO\....
Conventions:
- array-based methods remain available for backward compatibility
...Dto()methods return typed response objects- many array-based methods also accept request DTOs through union types
Examples of strict field objects:
- Request:
ChatMessage,InferenceRequest,EmbeddingsRequest,KeyRequest,GuardrailRequest - Response:
InferenceChoice,ModelInfo,KeyInfo,GuardrailInfo,ProviderInfo,EmbeddingVector - Enums:
ChatRole,ModelCategory,SupportedParameter(withenum|stringfallback in query DTOs)
API Coverage
Coverage is based on the OpenRouter OpenAPI specification retrieved on March 5, 2026.
Inference
chatCompletions(array $payload)->POST /chat/completionscompletions(array $payload)->POST /completions(Legacy-Alias)createMessages(array $payload)->POST /messagescreateResponses(array $payload)->POST /responsescreateEmbeddings(array $payload)->POST /embeddingslistEmbeddingsModels()->GET /embeddings/modelsgetGeneration(string $id)->GET /generation?id=...
Models And Providers
listModels(array $query = [])->GET /modelslistModelsCount()->GET /models/countlistModelsUser()->GET /models/userlistModelEndpoints(string $author, string $slug)->GET /models/{author}/{slug}/endpointslistProviders()->GET /providerslistEndpointsZdr()->GET /endpoints/zdr
Credits
getCredits()->GET /creditscreateCoinbaseCharge(array $payload)->POST /credits/coinbase
API Keys And Auth
getCurrentKey()->GET /keylistKeys(array $query = [])->GET /keysgetKey(string $hash)->GET /keys/{hash}createKeys(array $payload)/createKey(array $payload)->POST /keysupdateKeys(string $hash, array $payload)/updateKey(...)->PATCH /keys/{hash}deleteKeys(string $hash)/deleteKey(...)->DELETE /keys/{hash}exchangeAuthCodeForApiKey(array $payload)->POST /auth/keyscreateAuthorizationCode(array $payload)->POST /auth/keys/codegetUserActivity(?string $date = null)->GET /activity
Guardrails
listGuardrails(array $query = [])->GET /guardrailsgetGuardrail(string $id)->GET /guardrails/{id}createGuardrail(array $payload)->POST /guardrailsupdateGuardrail(string $id, array $payload)->PATCH /guardrails/{id}deleteGuardrail(string $id)->DELETE /guardrails/{id}listKeyAssignments(array $query = [])->GET /guardrails/assignments/keyslistMemberAssignments(array $query = [])->GET /guardrails/assignments/memberslistGuardrailKeyAssignments(string $id, array $query = [])->GET /guardrails/{id}/assignments/keyslistGuardrailMemberAssignments(string $id, array $query = [])->GET /guardrails/{id}/assignments/membersbulkAssignKeysToGuardrail(string $id, array $payload)->POST /guardrails/{id}/assignments/keysbulkUnassignKeysFromGuardrail(string $id, array $payload)->POST /guardrails/{id}/assignments/keys/removebulkAssignMembersToGuardrail(string $id, array $payload)->POST /guardrails/{id}/assignments/membersbulkUnassignMembersFromGuardrail(string $id, array $payload)->POST /guardrails/{id}/assignments/members/remove
Streaming / Raw Responses
Use requestRaw(...) for non-JSON responses such as SSE:
Error Handling
ApiException: non-2xx API responseTransportException: network or PSR-18 transport failureInvalidResponseException: invalid JSON or JSON encoding failure
Development
Run live integration tests with a real API key (optional):
The integration test suite currently verifies:
- live access to
getCurrentKey() - live access to
listModels() - live access to
getCredits() - live access to
listModelsCount() - live access to
listModelsUser() - live access to
listEmbeddingsModels() - a real embeddings request with
nvidia/llama-nemotron-embed-vl-1b-v2:free - live access to
listProviders() - live access to
listEndpointsZdr() - live access to
listModelEndpoints('stepfun', 'step-3.5-flash:free') - a real content query through
chat/completionswithstepfun/step-3.5-flash:free - a real content query through
responseswithstepfun/step-3.5-flash:free - a real content query through
messageswithstepfun/step-3.5-flash:free - a real streaming request through
requestRaw()against/responses - a real image-input query through
chat/completionswithgoogle/gemma-3-4b-it:free
Optional environment variables:
OPENROUTER_BASE_URL(default:https://openrouter.ai/api/v1)OPENROUTER_APP_URLOPENROUTER_APP_NAMEOPENROUTER_VISION_MODELOPENROUTER_TEST_IMAGE_URL
Lizenz
MIT
All versions of openrouter-wrapper with dependencies
php-http/discovery Version ^1.20
psr/http-client Version ^1.0
psr/http-message Version ^1.1 || ^2.0
nyholm/psr7 Version ^1.8