Skip to content

Commit

Permalink
Merge pull request #8 from moe-mizrak/dev
Browse files Browse the repository at this point in the history
readme is updated and full name is added to license
  • Loading branch information
moe-mizrak authored May 28, 2024
2 parents 86ddfee + 65dbfa7 commit 680cecc
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Mizrak
Copyright (c) 2024 Moe Mizrak

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
62 changes: 58 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,61 @@
# laravel-openrouter
Laravel package for OpenRouter (A unified interface for LLMs)

Check out the official website: https://openrouter.ai/
# Laravel OpenRouter

<br />

# 🚧 Under Construction 🚧
[![Latest Version on Packagist](www.my_link_for_packagist_image)](https://packagist.org/packages/myLinkHere)
[![](https://dcbadge.vercel.app/api/server/KBPhAPEJNj?style=flat)](https://discord.gg/KBPhAPEJNj)
<br />

This Laravel package provides an easy-to-use interface for integrating **[OpenRouter](https://openrouter.ai/)** into your Laravel applications. OpenRouter is a unified interface for Large Language Models (LLMs) that allows you to interact with various **[AI models](https://openrouter.ai/docs#models)** through a single API.

## Table of Contents

- [🤖 Requirements](#-requirements)
- [🏁 Get Started](#-get-started)
- [⚙️ Configuration](#-configuration)
- [🎨 Usage](#-usage)
- [📜 License](#-license)

## 🤖 Requirements

- **PHP 8.1** or **higher**

## 🏁 Get Started

You can **install** the package via composer:

```bash
composer require moe-mizrak/laravel-openrouter
```
You can **publish** the **config file** with:

```bash
php artisan vendor:publish --provider="MoeMizrak\LaravelOpenRouter\OpenRouterServiceProvider"
```
This is the contents of the **published config file**:

```php
return [
'api_endpoint' => env('OPENROUTER_API_ENDPOINT', 'https://openrouter.ai/api/v1/'),
'api_key' => env('OPENROUTER_API_KEY'),
];
```

## ⚙️ Configuration
After publishing the package configuration file, you'll need to add the following environment variables to your **.env** file:

```env
OPENROUTER_API_ENDPOINT=https://openrouter.ai/api/v1/
OPENROUTER_API_KEY=your_api_key
```

- OPENROUTER_API_ENDPOINT: The endpoint URL for the **OpenRouter API** (default: https://openrouter.ai/api/v1/).
- OPENROUTER_API_KEY: Your **API key** for accessing the OpenRouter API. You can obtain this key from the [OpenRouter dashboard](https://openrouter.ai/keys).

## 🎨 Usage

// TODO: Add usage instructions and examples

## 📜 License
Laravel OpenRouter is an open-sourced software licensed under the **[MIT license](LICENSE)**.
4 changes: 2 additions & 2 deletions tests/OpenRouterAPITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public function it_makes_chat_completion_api_request_with_open_router_specific_p
$modelOpenchat = 'openchat/openchat-7b:free';
$modelGryphe = 'gryphe/mythomist-7b:free';
$transforms = ['middle-out']; // default for all models
$models = [$modelOpenchat, $modelGryphe, $this->model];
$models = [$this->model, $modelOpenchat, $modelGryphe];
$route = RouteType::FALLBACK;
$provider = new ProviderPreferencesData([
'allow_fallbacks' => true,
Expand All @@ -465,7 +465,7 @@ public function it_makes_chat_completion_api_request_with_open_router_specific_p
/* ASSERT */
$this->assertInstanceOf(ResponseData::class, $response);
$this->assertNotNull($response->id);
$this->assertEquals($modelOpenchat, $response->model); // Assert first model
$this->assertEquals($this->model, $response->model); // Assert first model
$this->assertEquals('chat.completion', $response->object);
$this->assertNotNull($response->created);
$this->assertNotNull($response->usage->prompt_tokens);
Expand Down

0 comments on commit 680cecc

Please sign in to comment.