PHPackages                             nlpcloud/nlpcloud-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. nlpcloud/nlpcloud-client

ActiveLibrary[API Development](/categories/api)

nlpcloud/nlpcloud-client
========================

NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, paraphrasing, grammar and spelling correction, keywords and keyphrases extraction, chatbot, product description and ad generation, intent classification, text generation, image generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, tokenization, POS tagging, speech synthesis, embeddings, and dependency parsing. It is ready for production, served through a REST API. This is the PHP client for the API. More details here: https://nlpcloud.com. Documentation: https://docs.nlpcloud.com. Github: https://github.com/nlpcloud/nlpcloud-php

v1.0.41(1y ago)2523.9k—7.1%10[1 PRs](https://github.com/nlpcloud/nlpcloud-php/pulls)MITPHPPHP &gt;=7.2

Since Feb 16Pushed 1y ago1 watchersCompare

[ Source](https://github.com/nlpcloud/nlpcloud-php)[ Packagist](https://packagist.org/packages/nlpcloud/nlpcloud-client)[ Docs](http://github.com/nlpcloud/nlpcloud-php)[ RSS](/packages/nlpcloud-nlpcloud-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (30)Used By (0)

PHP Client For NLP Cloud
========================

[](#php-client-for-nlp-cloud)

This is the PHP client for the [NLP Cloud](https://nlpcloud.com) API. See the [documentation](https://docs.nlpcloud.com) for more details.

NLP Cloud serves high performance pre-trained or custom models for NER, sentiment-analysis, classification, summarization, dialogue summarization, paraphrasing, intent classification, product description and ad generation, chatbot, grammar and spelling correction, keywords and keyphrases extraction, text generation, image generation, code generation, question answering, automatic speech recognition, machine translation, language detection, semantic search, semantic similarity, tokenization, POS tagging, embeddings, and dependency parsing. It is ready for production, served through a REST API.

You can either use the NLP Cloud pre-trained models, fine-tune your own models, or deploy your own models.

If you face an issue, don't hesitate to raise it as a Github issue. Thanks!

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

[](#installation)

Install via composer.

Create a `composer.json` file containing at least the following:

```
{
    "require": {
        "nlpcloud/nlpcloud-client": "*"
    }
}
```

Then launch the following:

```
composer install
```

Examples
--------

[](#examples)

Here is a full example that summarizes a text using Facebook's Bart Large CNN model, with a fake token:

```
require 'vendor/autoload.php';

use NLPCloud\NLPCloud;

$client = new NLPCloud('bart-large-cnn', '');
echo json_encode($client->summarization('One month after the United States began what has become a
  troubled rollout of a national COVID vaccination campaign, the effort is finally
  gathering real steam. Close to a million doses -- over 951,000, to be more exact --
  made their way into the arms of Americans in the past 24 hours, the U.S. Centers
  for Disease Control and Prevention reported Wednesday. That s the largest number
  of shots given in one day since the rollout began and a big jump from the
  previous day, when just under 340,000 doses were given, CBS News reported.
  That number is likely to jump quickly after the federal government on Tuesday
  gave states the OK to vaccinate anyone over 65 and said it would release all
  the doses of vaccine it has available for distribution. Meanwhile, a number
  of states have now opened mass vaccination sites in an effort to get larger
  numbers of people inoculated, CBS News reported.'));
```

Here is a full example that does the same thing, but on a GPU:

```
require 'vendor/autoload.php';

use NLPCloud\NLPCloud;

$client = new NLPCloud('bart-large-cnn', '', True);
echo json_encode($client->summarization('One month after the United States began what has become a
  troubled rollout of a national COVID vaccination campaign, the effort is finally
  gathering real steam. Close to a million doses -- over 951,000, to be more exact --
  made their way into the arms of Americans in the past 24 hours, the U.S. Centers
  for Disease Control and Prevention reported Wednesday. That s the largest number
  of shots given in one day since the rollout began and a big jump from the
  previous day, when just under 340,000 doses were given, CBS News reported.
  That number is likely to jump quickly after the federal government on Tuesday
  gave states the OK to vaccinate anyone over 65 and said it would release all
  the doses of vaccine it has available for distribution. Meanwhile, a number
  of states have now opened mass vaccination sites in an effort to get larger
  numbers of people inoculated, CBS News reported.'));
```

Here is a full example that does the same thing, but on a French text:

```
require 'vendor/autoload.php';

use NLPCloud\NLPCloud;

$client = new NLPCloud('bart-large-cnn', '', True, 'fra_Latn');
echo json_encode($client->summarization('Sur des images aériennes, prises la veille par un vol de surveillance
  de la Nouvelle-Zélande, la côte d’une île est bordée d’arbres passés du vert
  au gris sous l’effet des retombées volcaniques. On y voit aussi des immeubles
  endommagés côtoyer des bâtiments intacts. « D’après le peu d’informations
  dont nous disposons, l’échelle de la dévastation pourrait être immense,
  spécialement pour les îles les plus isolées », avait déclaré plus tôt
  Katie Greenwood, de la Fédération internationale des sociétés de la Croix-Rouge.
  Selon l’Organisation mondiale de la santé (OMS), une centaine de maisons ont
  été endommagées, dont cinquante ont été détruites sur l’île principale de
  Tonga, Tongatapu. La police locale, citée par les autorités néo-zélandaises,
  a également fait état de deux morts, dont une Britannique âgée de 50 ans,
  Angela Glover, emportée par le tsunami après avoir essayé de sauver les chiens
  de son refuge, selon sa famille.'));
```

A json object is returned:

```
{
  "summary_text": "Over 951,000 doses were given in the past 24 hours. That's the largest number of shots given in one day since the  rollout began. That number is likely to jump quickly after the federal government gave states the OK to vaccinate anyone over 65. A number of states have now opened mass vaccination sites."
}
```

Usage
-----

[](#usage)

### Client Initialization

[](#client-initialization)

Pass the model you want to use and the NLP Cloud token to the client during initialization.

The model can either be a pretrained model like `en_core_web_lg`, `bart-large-mnli`... but also one of your custom models, using `custom_model/` (e.g. `custom_model/2568`).

Your token can be retrieved from your [NLP Cloud dashboard](https://nlpcloud.com/home/token).

```
use NLPCloud\NLPCloud;

$client = new NLPCloud('','');
```

If you want to use a GPU, pass `true` as a 3rd argument.

```
use NLPCloud\NLPCloud;

$client = new NLPCloud('','', true);
```

If you want to use the multilingual add-on in order to process non-English texts, set `''` as a 4th argument. For example, if you want to process French text, you should set `'fra_Latn'`.

```
use NLPCloud\NLPCloud;

$client = new NLPCloud('','', false, '');
```

If you want to make asynchronous requests, pass `true` as a 4th argument.

```
use NLPCloud\NLPCloud;

$client = new NLPCloud('', '', false, '', true);
```

If you are making asynchronous requests, you will always receive a quick response containing a URL. You should then poll this URL with `asyncResult()` on a regular basis (every 10 seconds for example) in order to check if the result is available. Here is an example:

```
$client->asyncResult('https://api.nlpcloud.io/v1/get-async-result/21718218-42e8-4be9-a67f-b7e18e03b436');
```

The above command returns an object if the response is availble. It returns nothing otherwise (`NULL`).

### Automatic Speech Recognition (Speech to Text) Endpoint

[](#automatic-speech-recognition-speech-to-text-endpoint)

Call the `asr()` method and pass the following arguments:

1. (Optional: either this or the encoded file should be set) `url`: a URL where your audio or video file is hosted
2. (Optional: either this or the url should be set) `encodedFile`: a base 64 encoded version of your file
3. (Optional) `inputLanguage`: the language of your file as ISO code

```
echo json_encode($client->asr(''));
```

The above command returns an object.

### Chatbot Endpoint

[](#chatbot-endpoint)

Call the `chatbot()` method and pass your input. As an option, you can also pass a context and a conversation history that is an array of named arrays. Each named array is made of an `input` and a `response` from the chatbot.

```
echo json_encode($client->chatbot('', '', array(array('input'=>'input 1','response'=>'response 1'), array('input'=>'input 2','response'=>'response 2'), ...)));
```

The above command returns an object.

### Classification Endpoint

[](#classification-endpoint)

Call the `classification()` method and pass 3 arguments:

1. The text you want to classify, as a string
2. The candidate labels for your text, as an array of strings
3. Whether the classification should be multi-class or not, as a boolean

```
echo json_encode($client->classification('', array('label 1', 'label 2', ...), True|False));
```

The above command returns an object.

### Code Generation Endpoint

[](#code-generation-endpoint)

Call the `codeGeneration()` method and pass the description of your program:

```
echo json_encode($client->codeGeneration(''));
```

The above command returns an object.

### Dependencies Endpoint

[](#dependencies-endpoint)

Call the `dependencies()` method and pass the text you want to perform part of speech tagging (POS) + arcs on.

```
echo json_encode($client->dependencies(''));
```

The above command returns an object.

### Embeddings Endpoint

[](#embeddings-endpoint)

Call the `embeddings()` method and pass an array of blocks of text that you want to extract embeddings from.

```
echo json_encode($client->embeddings(array('', '', '', ...)));
```

The above command returns an object.

### Entities Endpoint

[](#entities-endpoint)

Call the `entities()` method and pass the text you want to perform named entity recognition (NER) on.

```
echo json_encode($client->entities(''));
```

The above command returns an object.

### Generation Endpoint

[](#generation-endpoint)

Call the `generation()` method and pass the following arguments:

1. The block of text that starts the generated text. 256 tokens maximum for GPT-J on CPU, 1024 tokens maximum for GPT-J and GPT-NeoX 20B on GPU, and 2048 tokens maximum for Fast GPT-J and Finetuned GPT-NeoX 20B on GPU.
2. (Optional) `max_length`: Optional. The maximum number of tokens that the generated text should contain. 256 tokens maximum for GPT-J on CPU, 1024 tokens maximum for GPT-J and GPT-NeoX 20B on GPU, and 2048 tokens maximum for Fast GPT-J and Finetuned GPT-NeoX 20B on GPU. If `length_no_input` is false, the size of the generated text is the difference between `max_length` and the length of your input text. If `length_no_input` is true, the size of the generated text simply is `max_length`. Defaults to 50.
3. (Optional) `length_no_input`: Whether `min_length` and `max_length` should not include the length of the input text, as a boolean. If false, `min_length` and `max_length` include the length of the input text. If true, min\_length and `max_length` don't include the length of the input text. Defaults to false.
4. (Optional) `end_sequence`: A specific token that should be the end of the generated sequence, as a string. For example if could be `.` or `\n` or `###` or anything else below 10 characters.
5. (Optional) `remove_input`: Whether you want to remove the input text form the result, as a boolean. Defaults to false.
6. (Optional) `num_beams`: Number of beams for beam search. 1 means no beam search. This is an integer. Defaults to 1.
7. (Optional) `num_return_sequences`: The number of independently computed returned sequences for each element in the batch, as an integer. Defaults to 1.
8. (Optional) `top_k`: The number of highest probability vocabulary tokens to keep for top-k-filtering, as an integer. Maximum 1000 tokens. Defaults to 0.
9. (Optional) `top_p`: If set to float &lt; 1, only the most probable tokens with probabilities that add up to top\_p or higher are kept for generation. This is a float. Should be between 0 and 1. Defaults to 0.7.
10. (Optional) `temperature`: The value used to module the next token probabilities, as a float. Should be between 0 and 1. Defaults to 1.
11. (Optional) `repetition_penalty`: The parameter for repetition penalty, as a float. 1.0 means no penalty. Defaults to 1.0.
12. (Optional) `bad_words`: List of tokens that are not allowed to be generated, as a list of strings. Defaults to null.
13. (Optional) `remove_end_sequence`: Optional. Whether you want to remove the `end_sequence` string from the result. Defaults to false.

```
echo json_encode($client->generation(''));
```

### Grammar and Spelling Correction Endpoint

[](#grammar-and-spelling-correction-endpoint)

Call the `gsCorrection()` method and pass the text you want correct:

```
echo json_encode($client->gsCorrection(''));
```

The above command returns an object.

### Image Generation Endpoint

[](#image-generation-endpoint)

Call the `imageGeneration()` method and pass the text you want to use to generate your image:

```
echo json_encode($client->imageGeneration(''));
```

The above command returns an object.

### Intent Classification Endpoint

[](#intent-classification-endpoint)

Call the `intentClassification()` method and pass the text you want to extract intents from:

```
echo json_encode($client->intentClassification(''));
```

The above command returns an object.

### Keywords and Keyphrases Extraction Endpoint

[](#keywords-and-keyphrases-extraction-endpoint)

Call the `kwKpExtraction()` method and pass the text you want to extract keywords and keyphrases from:

```
echo json_encode($client->kwKpExtraction(''));
```

The above command returns an object.

### Language Detection Endpoint

[](#language-detection-endpoint)

Call the `langdetection()` method and pass the text you want to analyze.

```
echo json_encode($client->langdetection(''));
```

The above command returns an object.

### Paraphrasing Endpoint

[](#paraphrasing-endpoint)

Call the `paraphrasing()` method and pass the text you want to paraphrase.

```
echo json_encode($client->paraphrasing(''));
```

The above command returns an object.

### Question Answering Endpoint

[](#question-answering-endpoint)

Call the `question()` method and pass the following:

1. Your question
2. (Optional) A context that the model will use to try to answer your question

```
echo json_encode($client->question('',''));
```

The above command returns an object.

### Semantic Search Endpoint

[](#semantic-search-endpoint)

Call the `semanticSearch()` method and pass your search query:

```
echo json_encode($client->semanticSearch(''));
```

The above command returns an object.

### Semantic Similarity Endpoint

[](#semantic-similarity-endpoint)

Call the `semanticSimilarity()` method and pass an array made up of 2 blocks of text that you want to compare.

```
echo json_encode($client->semanticSimilarity(array('', '')));
```

The above command returns an object.

### Sentence Dependencies Endpoint

[](#sentence-dependencies-endpoint)

Call the `sentenceDependencies()` method and pass a block of text made up of several sentencies you want to perform POS + arcs on.

```
echo json_encode($client->sentenceDependencies(''));
```

The above command returns an object.

### Sentiment Analysis Endpoint

[](#sentiment-analysis-endpoint)

Call the `sentiment()` method and pass the following:

1. The text you want to analyze and get the sentiment of
2. (Optional) The target element that the sentiment should apply to

```
echo json_encode($client->sentiment('', ''));
```

The above command returns an object.

### Speech Synthesis Endpoint

[](#speech-synthesis-endpoint)

Call the `speechSynthesis()` method and pass the text you want to convert to audio:

```
echo json_encode($client->speechSynthesis(''));
```

The above command returns a JSON object.

### Summarization Endpoint

[](#summarization-endpoint)

Call the `summarization()` method and pass the text you want to summarize.

```
echo json_encode($client->summarization(''));
```

The above command returns an object.

### Tokenization Endpoint

[](#tokenization-endpoint)

Call the `tokens()` method and pass the text you want to tokenize.

```
echo json_encode($client->tokens(''));
```

The above command returns an object.

### Translation Endpoint

[](#translation-endpoint)

Call the `translation()` method and pass the text you want to translate.

```
echo json_encode($client->translation(''));
```

The above command returns an object.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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 ~49 days

Recently: every ~135 days

Total

29

Last Release

538d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/69dc33bb1700db15f306450524dbd40a38b9037e6cc7110cb829efedb62bdc57?d=identicon)[juliensalinas](/maintainers/juliensalinas)

---

Top Contributors

[![phingoc1](https://avatars.githubusercontent.com/u/61778162?v=4)](https://github.com/phingoc1 "phingoc1 (3 commits)")[![kenny-caldieraro](https://avatars.githubusercontent.com/u/81420460?v=4)](https://github.com/kenny-caldieraro "kenny-caldieraro (2 commits)")

---

Tags

ad-generatorchatbotcode-generationembeddingsgrammar-correctionintent-classificationkeyword-extractionlanguage-detectionmachine-translationnernlpparaphrasingquestion-answeringsemantic-similaritysentiment-analysistext-classificationtext-generationtext-summarizationtokenizationapiainlpmachine learningdata scienceDeep learningnlpcloud

### Embed Badge

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

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

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[davmixcool/php-sentiment-analyzer

PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool that is used to understand sentiments in a sentence using VADER (Valence Aware Dictionary and sentiment Reasoner).

138151.7k1](/packages/davmixcool-php-sentiment-analyzer)[grok-php/laravel

Seamlessly integrate Grok AI into Laravel applications with an elegant, developer-friendly package. Leverage powerful AI models for chat, automation, and NLP while maintaining Laravel's expressive simplicity.

1633.4k](/packages/grok-php-laravel)[qwen-php/qwen-php-client

robust and community-driven PHP SDK library for seamless integration with the qwen AI API, offering efficient access to advanced AI and data processing capabilities

213.2k1](/packages/qwen-php-qwen-php-client)[rubix/server

Deploy your Rubix ML models to production with scalable stand-alone inference servers.

632.3k](/packages/rubix-server)

PHPackages © 2026

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