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. level7up/openrouter-client

ActiveLibrary

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

OpenRouter API client for Laravel

2.0(1y ago)2103MITPHPPHP ^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 1mo ago

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 68% of packages

Maintenance50

Moderate activity, may be stable

Popularity16

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

366d ago

Major Versions

1.0 → 2.02025-05-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf0e884d5d8af4716ceca4ecaf21f3392cffe9e339fe3f215ec425915d4d14c1?d=identicon)[level7up](/maintainers/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

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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