PHPackages                             level7up/openrouter-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. level7up/openrouter-client

ActiveLibrary[API Development](/categories/api)

level7up/openrouter-client
==========================

OpenRouter API client for Laravel

2.0(1y ago)2299MITPHPPHP ^8.0

Since May 15Pushed 1y ago1 watchersCompare

[ Source](https://github.com/level7up/openrouter-client)[ Packagist](https://packagist.org/packages/level7up/openrouter-client)[ RSS](/packages/level7up-openrouter-client/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (3)Used By (0)

OpenRouter Client for Laravel
=============================

[](#openrouter-client-for-laravel)

A simple Laravel wrapper for the [OpenRouter API](https://openrouter.ai/) to easily perform chat completions using models like `openai/gpt-4o`.

---

🧰 Features
----------

[](#-features)

- Easy integration with Laravel via Service Provider
- Customizable via `.env` or `config/openrouter.php`
- Uses Guzzle for HTTP requests
- Supports `max_tokens` for response control

---

🚀 Installation
--------------

[](#-installation)

Require the package via Composer:

```
composer require level7up/openrouter-client
```

---

🛠 Configuration
---------------

[](#-configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=config
```

Add your credentials to `.env`:

```
OPENROUTER_API_KEY=your_openrouter_api_key
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
OPENROUTER_REFERER=https://your-site.com        # optional
OPENROUTER_SITE_TITLE=Your Site Name            # optional
```

---

🧪 Usage
-------

[](#-usage)

Inject the client into your controller or service:

```
use Level7up\OpenRouter\OpenRouterClient;

class ChatController extends Controller
{
    public function ask(OpenRouterClient $client)
    {
        $response = $client->getCompletion('Tell me a joke.', 50);
        return response()->json(['reply' => $response]);
    }
}
```

---

⚙️ Configuration File
---------------------

[](#️-configuration-file)

After publishing, you can modify `config/openrouter.php`:

```
return [
    'api_key'    => env('OPENROUTER_API_KEY'),
    'base_url'   => env('OPENROUTER_BASE_URL', 'https://openrouter.ai/api/v1'),
    'referer'    => env('OPENROUTER_REFERER'),
    'site_title' => env('OPENROUTER_SITE_TITLE'),
];
```

---

📚 API Reference
---------------

[](#-api-reference)

### `getCompletion(string $prompt, int $maxTokens = 100): ?string`

[](#getcompletionstring-prompt-int-maxtokens--100-string)

Sends a prompt to the OpenRouter API and returns the response string.

---

✅ Requirements
--------------

[](#-requirements)

- PHP 8.0+
- Laravel 8+
- Guzzle 7+

---

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

---

🧠 About
-------

[](#-about)

Maintained by [Level7up](https://github.com/level7up). Contributions and issues are welcome!

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance46

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

414d ago

Major Versions

1.0 → 2.02025-05-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/47832762?v=4)[Abdulalim Mohamed](/maintainers/level7up)[@level7up](https://github.com/level7up)

---

Top Contributors

[![level7up](https://avatars.githubusercontent.com/u/47832762?v=4)](https://github.com/level7up "level7up (3 commits)")

### Embed Badge

![Health badge](/badges/level7up-openrouter-client/health.svg)

```
[![Health](https://phpackages.com/badges/level7up-openrouter-client/health.svg)](https://phpackages.com/packages/level7up-openrouter-client)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.8k3.6M985](/packages/statamic-cms)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M47](/packages/tencentcloud-tencentcloud-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

273.0k](/packages/eslazarev-wildberries-sdk)[files.com/files-php-sdk

Files.com PHP SDK

2481.1k](/packages/filescom-files-php-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
