PHPackages                             takaaki-mizuno/llm-json-adapter - 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. takaaki-mizuno/llm-json-adapter

ActiveLibrary

takaaki-mizuno/llm-json-adapter
===============================

0.1.0(2y ago)14MITPHPPHP ^8.2

Since Apr 28Pushed 2y ago1 watchersCompare

[ Source](https://github.com/takaaki-mizuno/php-llm-json-adapter)[ Packagist](https://packagist.org/packages/takaaki-mizuno/llm-json-adapter)[ RSS](/packages/takaaki-mizuno-llm-json-adapter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (2)Used By (0)

LLM JSON Adapter
================

[](#llm-json-adapter)

What is it ?
------------

[](#what-is-it-)

When using LLMs from the system, you often expect to get output results in JSON: OpenAPI's GPT API has a mechanism called Function Calling, which can return JSON, but Google's Gemini does not seem to have that functionality.

Therefore, I have created a wrapper library to switch LLMs and get results in JSON. What this library can do is as follows.

- Allows you to define the results you want to get in JSON Schema
- Switch between LLMs (currently supports OpenAI's GPT and Google's Gemini).
- Retry a specified number of times if the JSON retrieval fails

Installation
------------

[](#installation)

```
composer require takaaki-mizuno/llm-json-adapter
```

How to use
----------

[](#how-to-use)

Use the following code to get the results in JSON.

### OpenAI

[](#openai)

```
$instance = new LLMJsonAdapter(
    providerName: "openai",
    attributes: [
        "api_key" => "[API-KEY]",
        "model" => "gpt-3.5-turbo",
    ],
    maximumRetryCount: 3,
    model: "gpt-3.5-turbo",
    defaultLanguage: "en"
);

$response = new \TakaakiMizuno\LLMJsonAdapter\Models\Response(
    name: "response data name",
    description: "response data description",
    schema: [JSON SCHEMA]
);
```

### Google Gemini

[](#google-gemini)

```
$instance = new LLMJsonAdapter(
    providerName: "google",
    attributes: [
        "api_key" => "[API-KEY]",
        "model" => "gemini-1.5-pro-latest",
    ],
    maximumRetryCount: 3,
    defaultLanguage: "en"
);

$response = new \TakaakiMizuno\LLMJsonAdapter\Models\Response(
    name: "response data name",
    description: "response data description",
    schema: [JSON SCHEMA]
);
```

### BedRock

[](#bedrock)

```
$instance = new LLMJsonAdapter(
    providerName: "bedrock",
    attributes: [
        'accessKeyId' => '[ACCESS-KEY]',
        'secretAccessKey' => '[SECRET-KEY]',
        'model' => 'anthropic.claude-3-haiku-20240307-v1:0',
    ],
    maximumRetryCount: 3,
    defaultLanguage: "en"
);

$response = new \TakaakiMizuno\LLMJsonAdapter\Models\Response(
    name: "response data name",
    description: "response data description",
    schema: [JSON SCHEMA]
);
```

### Ollama

[](#ollama)

```
$instance = new LLMJsonAdapter(
    providerName: "ollama",
    attributes: [
        'url' => "http://localhost:11434",
        'model' => 'llama3',
    ],
    maximumRetryCount: 3,
    defaultLanguage: "en"
);

$response = new \TakaakiMizuno\LLMJsonAdapter\Models\Response(
    name: "response data name",
    description: "response data description",
    schema: [JSON SCHEMA]
);
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

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

Unknown

Total

1

Last Release

745d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e5b61446c44adb8ff13bae8fca7678631d99f07c4078e21a7e1715cc2a3554a?d=identicon)[takaaki-mizuno](/maintainers/takaaki-mizuno)

---

Top Contributors

[![takaaki-mizuno](https://avatars.githubusercontent.com/u/1115366?v=4)](https://github.com/takaaki-mizuno "takaaki-mizuno (3 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/takaaki-mizuno-llm-json-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/takaaki-mizuno-llm-json-adapter/health.svg)](https://phpackages.com/packages/takaaki-mizuno-llm-json-adapter)
```

###  Alternatives

[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[laravel-notification-channels/aws-sns

Amazon Simple Notification Service (AWS SNS) notification channel for Laravel.

541.1M2](/packages/laravel-notification-channels-aws-sns)[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)[ellaisys/aws-cognito

AWS Cognito package that allows Auth and other related features using the AWS SDK for PHP

120220.7k1](/packages/ellaisys-aws-cognito)[georgeboot/laravel-echo-api-gateway

Use Laravel Echo with API Gateway Websockets

10435.5k](/packages/georgeboot-laravel-echo-api-gateway)[keboola/storage-api-client

Keboola Storage API PHP Client

10387.5k25](/packages/keboola-storage-api-client)

PHPackages © 2026

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