PHPackages                             mirage-ai/php-mirage-api - 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. mirage-ai/php-mirage-api

AbandonedArchivedLibrary[API Development](/categories/api)

mirage-ai/php-mirage-api
========================

Mirage API PHP wrapper.

1.7.0(1y ago)03MITPHPPHP &gt;=5.4.0

Since Jun 7Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (12)Used By (0)

php-mirage-api
==============

[](#php-mirage-api)

[![Build and Release](https://github.com/mirage-ai-com/php-mirage-api/workflows/Build%20and%20Release/badge.svg)](https://github.com/mirage-ai-com/php-mirage-api/actions?query=workflow%3A%22Build+and+Release%22) [![Version](https://camo.githubusercontent.com/145a764d0769e494b7c5c2395b6dabb8758a5f121e1d2f06ac844c380a0b9c4a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d69726167652d61692f7068702d6d69726167652d6170692e737667)](https://packagist.org/packages/mirage-ai/php-mirage-api) [![Downloads](https://camo.githubusercontent.com/3a92851d2809e8387a4905e3180624aef48eb4e389e2d977da8786b5e2215174/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d69726167652d61692f7068702d6d69726167652d6170692e737667)](https://packagist.org/packages/mirage-ai/php-mirage-api)

The Mirage API NodeJS wrapper. Access AI inference services.

Copyright 2023 Crisp IM SAS. See LICENSE for copying information.

- **📝 Implements**: [API Reference (V1)](https://docs.mirage-ai.com/references/api/v1/) at revision: 19/12/2023
- **😘 Maintainer**: [@valeriansaliou](https://github.com/valeriansaliou)

Usage
-----

[](#usage)

Install the library:

```
composer require mirage-ai/php-mirage-api
```

Then, import it:

```
require __DIR__."/vendor/autoload.php";
```

Construct a new authenticated Mirage client with your `user_id` and `secret_key` tokens.

```
$client = new Mirage("ui_xxxxxx", "sk_xxxxxx");
```

Then, consume the client eg. to transcribe a audio file containing speech to text:

```
$data = $client->task->transcribeSpeech([
  "locale" => [
    "to" => "en"
  ],

  "media" => [
    "type" => "audio/webm",
    "url" => "https://files.mirage-ai.com/dash/terminal/samples/transcribe-speech/hey-there.weba"
  ]
]);
```

Authentication
--------------

[](#authentication)

To authenticate against the API, get your tokens (`user_id` and `secret_key`).

Then, pass those tokens **once** when you instanciate the Mirage client as following:

```
# Make sure to replace 'user_id' and 'secret_key' with your tokens
$client = new Mirage("user_id", "secret_key");
```

Resource Methods
----------------

[](#resource-methods)

This library implements all methods the Mirage API provides. See the [API docs](https://docs.mirage-ai.com/references/api/v1/) for a reference of available methods, as well as how returned data is formatted.

### Task API

[](#task-api)

#### ➡️ Transcribe Speech

[](#️-transcribe-speech)

- **Method:** `$client->task->transcribeSpeech(data)`
- **Reference:** [Transcribe Speech](https://docs.mirage-ai.com/references/api/v1/#transcribe-speech)
- **Request:**

```
$client->task->transcribeSpeech([
  "locale" => [
    "to" => "en"
  ],

  "media" => [
    "type" => "audio/webm",
    "url" => "https://files.mirage-ai.com/dash/terminal/samples/transcribe-speech/hey-there.weba"
  ]
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "locale": "en",

    "parts": [
      {
        "start": 5.0,
        "end": 9.0,
        "text": " I'm just speaking some seconds to see if the translation is correct"
      }
    ]
  }
}
```

#### ➡️ Answer Prompt

[](#️-answer-prompt)

- **Method:** `$client->task->answerPrompt(data)`
- **Reference:** [Answer Prompt](https://docs.mirage-ai.com/references/api/v1/#answer-prompt)
- **Request:**

```
$client->task->answerPrompt([
  "prompt" => "Generate an article about Alpacas"
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "answer": "The alpaca (Lama pacos) is a species of South American camelid mammal. It is similar to, and often confused with, the llama. However, alpacas are often noticeably smaller than llamas. The two animals are closely related and can successfully crossbreed. Both species are believed to have been domesticated from their wild relatives, the vicuña and guanaco. There are two breeds of alpaca: the Suri alpaca and the Huacaya alpaca."
  }
}
```

#### ➡️ Answer Question

[](#️-answer-question)

- **Method:** `$client->task->answerQuestion(data)`
- **Reference:** [Answer Question](https://docs.mirage-ai.com/references/api/v1/#answer-question)
- **Request:**

```
$client->task->answerQuestion([
  "question" => "Should I pay more for that?",

  "answer" => [
    "start" => "Sure,"
  ],

  "context" => [
    "primary_id" => "cf4ccdb5-df44-4668-a9e7-3ab31bebf89b",

    "conversation" => [
      "messages" => [
        [
          "from" => "customer",
          "text" => "Hey there!"
        ],

        [
          "from" => "agent",
          "text" => "Hi. How can I help?"
        ],

        [
          "from" => "customer",
          "text" => "I want to add more sub-domains to my website."
        ]
      ]
    ]
  ]
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "answer": "You can add the Crisp chatbox to your website by following this guide: https://help.crisp.chat/en/article/how-to-add-crisp-chatbox-to-your-website-dkrg1d/ :)",
    "sources": []
  }
}
```

#### ➡️ Summarize Paragraphs

[](#️-summarize-paragraphs)

- **Method:** `$client->task->summarizeParagraphs(data)`
- **Reference:** [Summarize Paragraphs](https://docs.mirage-ai.com/references/api/v1/#summarize-paragraphs)
- **Request:**

```
$client->task->summarizeParagraphs([
  "paragraphs" => [
    [
      "text" => "GPT-4 is getting worse over time, not better."
    ],

    [
      "text" => "Many people have reported noticing a significant degradation in the quality of the model responses, but so far, it was all anecdotal."
    ]
  ]
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "summary": "GPT-4 is getting worse over time, not better. We have a new version of GPT-4 that is not improving, but it is regressing."
  }
}
```

#### ➡️ Summarize Conversation

[](#️-summarize-conversation)

- **Method:** `$client->task->summarizeConversation(data)`
- **Reference:** [Summarize Conversation](https://docs.mirage-ai.com/references/api/v1/#summarize-conversation)
- **Request:**

```
$client->task->summarizeConversation([
  "transcript" => [
    [
      "name" => "Valerian",
      "text" => "Hello! I have a question about the Crisp chatbot, I am trying to setup a week-end auto-responder, how can I do that?"
    ],

    [
      "name" => "Baptiste",
      "text" => "Hi. Baptiste here. I can provide you an example bot scenario that does just that if you'd like?"
    ]
  ]
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "summary": "Valerian wants to set up a week-end auto-responder on Crisp chatbot. Baptiste can give him an example."
  }
}
```

#### ➡️ Categorize Conversations

[](#️-categorize-conversations)

- **Method:** `$client->task->categorizeConversations(data)`
- **Reference:** [Categorize Conversations](https://docs.mirage-ai.com/references/api/v1/#categorize-conversations)
- **Request:**

```
$client->task->categorizeConversations([
  "conversations" => [
    [
      "transcript" => [
        [
          "from" => "customer",
          "text" => "Hello! I have a question about the Crisp chatbot, I am trying to setup a week-end auto-responder, how can I do that?"
        ],

        [
          "from" => "agent",
          "text" => "Hi. Baptiste here. I can provide you an example bot scenario that does just that if you'd like?"
        ]
      ]
    ]
  ]
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "categories": [
      "Chatbot Configuration Issue"
    ]
  }
}
```

#### ➡️ Rank Question

[](#️-rank-question)

- **Method:** `$client->task->rankQuestion(data)`
- **Reference:** [Rank Question](https://docs.mirage-ai.com/references/api/v1/#rank-question)
- **Request:**

```
$client->task->rankQuestion([
  "question" => "Hi! I am having issues setting up DNS records for my Crisp helpdesk. Can you help?",

  "context" => [
    "source" => "helpdesk",
    "primary_id" => "cf4ccdb5-df44-4668-a9e7-3ab31bebf89b"
  ]
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "results": [
      {
        "id": "15fd3f24-56c8-435e-af8e-c47d4cd6115c",
        "score": 9,
        "grouped_text": "Setup your Helpdesk domain name\ntutorials for most providers",

        "items": [
          {
            "source": "helpdesk",
            "primary_id": "51a32e4c-1cb5-47c9-bcc0-3e06f0dce90a",
            "secondary_id": "15fd3f24-56c8-435e-af8e-c47d4cd6115c",
            "text": "Setup your Helpdesk domain name\ntutorials for most providers",
            "timestamp": 1682002198552,

            "metadata": {
              "title": "Setup your Helpdesk domain name"
            }
          }
        ]
      }
    ]
  }
}
```

#### ➡️ Translate Text

[](#️-translate-text)

- **Method:** `$client->task->translateText(data)`
- **Reference:** [Translate Text](https://docs.mirage-ai.com/references/api/v1/#translate-text)
- **Request:**

```
$client->task->translateText([
  "locale" => [
    "from" => "fr",
    "to" => "en"
  ],

  "type" => "html",
  "text" => "Bonjour, comment puis-je vous aider Mr Saliou ?"
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "translation": "Hi, how can I help you Mr Saliou?"
  }
}
```

#### ➡️ Fraud Spamicity

[](#️-fraud-spamicity)

- **Method:** `$client->task->fraudSpamicity(data)`
- **Reference:** [Fraud Spamicity](https://docs.mirage-ai.com/references/api/v1/#fraud-spamicity)
- **Request:**

```
$client->task->fraudSpamicity([
  "name" => "Crisp",
  "domain" => "crisp.chat",
  "email_domain" => "mail.crisp.chat"
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "fraud": false,
    "score": 0.13
  }
}
```

#### ➡️ Spam Conversation

[](#️-spam-conversation)

- **Method:** `$client->task->spamConversation(data)`
- **Reference:** [Spam Conversation](https://docs.mirage-ai.com/references/api/v1/#spam-conversation)
- **Request:**

```
$client->task->spamConversation([
  "sender" => [
    "name" => "John Doe",
    "email" => "john@example.com"
  ],

  "transcript" => [
    [
      "from" => "customer",
      "origin" => "chat",
      "text" => "Hello, I would like to discuss your services"
    ]
  ]
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "class": "spam",
    "confidence": 0.93,
    "logprob": -0.10,

    "scores": {
      "gibberish": 0.0,
      "marketing": 0.45,
      "regular": 0.0,
      "spam": 0.93
    }
  }
}
```

#### ➡️ Spam Document

[](#️-spam-document)

- **Method:** `$client->task->spamDocument(data)`
- **Reference:** [Spam Document](https://docs.mirage-ai.com/references/api/v1/#spam-document)
- **Request:**

```
$client->task->spamDocument([
  "name" => "Spammy Domain",
  "domain" => "spammy-domain.crisp.help",
  "title" => "Spammy title",
  "content" => "Spammy content"
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "class": "spam",
    "confidence": 0.82,
    "logprob": -0.10,

    "scores": {
      "gibberish": null,
      "marketing": null,
      "regular": 0.0,
      "spam": 0.82
    }
  }
}
```

### Data API

[](#data-api)

#### ➡️ Context Ingest

[](#️-context-ingest)

- **Method:** `$client->data->contextIngest(data)`
- **Reference:** [Ingest Context Data](https://docs.mirage-ai.com/references/api/v1/#ingest-context-data)
- **Request:**

```
$client->data->contextIngest([
  "items" => [
    [
      "operation": "index",
      "primary_id" => "pri_cf44dd72-4ba9-4754-8fb3-83c4261243c4",
      "secondary_id" => "sec_6693a4a2-e33f-4cce-ba90-b7b5b0922c46",
      "tertiary_id" => "ter_de2bd6e7-74e1-440d-9a23-01964cd4b7da",

      "text" => "Text to index here...",
      "source" => "chat",
      "timestamp" => 1682002198552,

      "metadata" => [
        "custom_key" => "custom_value",
        "another_key" => "another_value"
      ]
    ]
  ]
]);
```

- **Response:**

```
{
  "reason": "processed",

  "data": {
    "imported": true
  }
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance46

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

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 ~66 days

Recently: every ~122 days

Total

11

Last Release

411d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fae094db8783d3a1f6df64bedf6845173d92492b0ac8909d9c059055693fb294?d=identicon)[mirage-ai](/maintainers/mirage-ai)

---

Top Contributors

[![valeriansaliou](https://avatars.githubusercontent.com/u/1451907?v=4)](https://github.com/valeriansaliou "valeriansaliou (31 commits)")

---

Tags

phpwrapper

### Embed Badge

![Health badge](/badges/mirage-ai-php-mirage-api/health.svg)

```
[![Health](https://phpackages.com/badges/mirage-ai-php-mirage-api/health.svg)](https://phpackages.com/packages/mirage-ai-php-mirage-api)
```

###  Alternatives

[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/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)

PHPackages © 2026

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