PHPackages                             renannazar/laravel-openai-context - 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. renannazar/laravel-openai-context

ActiveLibrary[API Development](/categories/api)

renannazar/laravel-openai-context
=================================

Laravel using openai for context question

10PHP

Since Nov 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/renannazar/laravel-openai-context)[ Packagist](https://packagist.org/packages/renannazar/laravel-openai-context)[ RSS](/packages/renannazar-laravel-openai-context/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

---

**OpenAI Context** for Laravel is a community-maintained library that allows you to ask question using a context. This library also allow you to ask question without a context, but keep in mind that gpt 3.5 using old data (2021 or lower) so when using a context from url, you can ask anything with that

> **Note:** This repository contains the integration code of the **OpenAI PHP for Laravel** for Laravel().

Get Started
-----------

[](#get-started)

> **Requires [PHP 8.1+](https://php.net/releases/)**

First, install OpenAI Context via the [Composer](https://getcomposer.org/) package manager:

```
composer require renannazar/laravel-openai-context
```

Next, publish the configuration file:

```
php artisan vendor:publish --provider="OpenAI\Laravel\ServiceProvider"
```

This will create a `config/openai.php` configuration file in your project, which you can modify to your needs using environment variables:

```
OPENAI_API_KEY=sk-...
```

You can get OpenAi Api Key ()

Finally, you may use the `OpenAI` facade to access the OpenAI API:

```
use Renannazar\LaravelOpenaiContext\Facades\OpenaiContext;

$url = "https://newsorarticle.com";
$question = "ask anything about that url";

$result = OpenaiContext::askContextByUrl($url, $question);
//$result = OpenaiContext::askContextByText($text, $question); -> for text only without url

return $result['content']; // array
```

Configuration
-------------

[](#configuration)

Configuration is done via environment variables or directly in the configuration file (`config/openai.php`).

### OpenAI API Key and Organization

[](#openai-api-key-and-organization)

Specify your OpenAI API Key and organization. This will be used to authenticate with the OpenAI API - you can find your API key and organization on your OpenAI dashboard, at .

```
OPENAI_API_KEY=
OPENAI_ORGANIZATION=
```

### Request Timeout

[](#request-timeout)

The timeout may be used to specify the maximum number of seconds to wait for a response. By default, the client will time out after 30 seconds.

```
OPENAI_REQUEST_TIMEOUT=
```

OpenAI Context for Laravel is an open-sourced software licensed under the **[MIT license](https://opensource.org/licenses/MIT)**.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity20

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ff2d48fa023e6ca5e7f8c2d203e8b922be32022b10561274efc3dd89cfca6e3?d=identicon)[renannazar](/maintainers/renannazar)

---

Top Contributors

[![renannazar](https://avatars.githubusercontent.com/u/16731299?v=4)](https://github.com/renannazar "renannazar (2 commits)")

### Embed Badge

![Health badge](/badges/renannazar-laravel-openai-context/health.svg)

```
[![Health](https://phpackages.com/badges/renannazar-laravel-openai-context/health.svg)](https://phpackages.com/packages/renannazar-laravel-openai-context)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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