# PhoenixLLM

{% hint style="info" %}
**Good to know:** All LLM interfaces need to use token as the request header.
{% endhint %}

## Buy LLM Token

<mark style="color:green;">`POST`</mark> `https://www.phoenix.global/sdk/computation/LLM/buyLLMToken`

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

#### Request Body

| Name                                        | Type    | Description                          |
| ------------------------------------------- | ------- | ------------------------------------ |
| tokensNum<mark style="color:red;">\*</mark> | integer | The number of tokens to be purchased |
| jobName<mark style="color:red;">\*</mark>   | string  | Job name                             |

{% tabs %}
{% tab title="200: OK Return the id of the new job" %}

```json
{
    "code": 200,
    "msg": "success",
    "jobID": "15336929879565052031766977071313450079096374296015479727460579121350576553341"
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/LLM/buyLLMToken' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNzM4Mjh9.7Qy6jh5L1qvVVbOZYR3JrmWdothI2SCF-oGyC2BfZDs' \
--header 'Content-Type: application/json' \
--data '{
  "tokensNum": 1000,
  "jobName": "LLM job"
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
  "github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
  "github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
  tokenStr := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNzM4Mjh9.7Qy6jh5L1qvVVbOZYR3JrmWdothI2SCF-oGyC2BfZDs"
  reqJSON := common.ReqBuyLlmToken{
    UserToken: tokenStr,
    JobName:   "Buy llm token 31",
    TokensNum: 1000,
  }
  result, err := controllers.BuyLLMToken(reqJSON)
  ...
}
```

{% endtab %}
{% endtabs %}

## Query Token price&#x20;

<mark style="color:blue;">`GET`</mark> `https://www.phoenix.global/sdk/computation/LLM/queryLLMPrice`

Querying the price of LLM token, priced in *ccd*

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

{% tabs %}
{% tab title="200: OK Return job list" %}

```json
{
  "code": 200,
  "data": {
    "price": "0.000007142857"
  },
  "msg": "success"
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/LLM/queryLLMPrice' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNzM4Mjh9.7Qy6jh5L1qvVVbOZYR3JrmWdothI2SCF-oGyC2BfZDs'
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
  "github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
  tokenStr := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNzM4Mjh9.7Qy6jh5L1qvVVbOZYR3JrmWdothI2SCF-oGyC2BfZDs"
  result, err := controllers.QueryLLMPrice(tokenStr)
  ...
}
```

{% endtab %}
{% endtabs %}

## Default LLM

<mark style="color:orange;">`POST`</mark> `https://www.phoenix.global/sdk/computation/LLM/callLLM3`

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

#### Request Body

| Name                                     | Type   | Description                                                    |
| ---------------------------------------- | ------ | -------------------------------------------------------------- |
| prompt<mark style="color:red;">\*</mark> | string | Prompt                                                         |
| max\_new\_tokens                         | int    | The maximum number of tokens that can be consumed by this call |

#### Response

{% tabs %}
{% tab title="200: OK Return the result" %}

```json
{
    "code": 200,
    "msg": "success",
    "text": "Blockchain is a distributed digital ledger technology...",
    "tokens_balance": 1534425
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/LLM/callLLM3' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNzM4Mjh9.7Qy6jh5L1qvVVbOZYR3JrmWdothI2SCF-oGyC2BfZDs' \
--header 'Content-Type: application/json' \
--data '{
    "prompt": "what is blockchain"
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
  "github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
  "github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
  tokenStr := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNzM4Mjh9.7Qy6jh5L1qvVVbOZYR3JrmWdothI2SCF-oGyC2BfZDs"
  reqJSON := common.ReqLLM3{
    UserToken: tokenStr,
    Prompt:    "what is blockchain",
  }
  result, err := controllers.CallLLM3(reqJSON)
  ...
}

```

{% endtab %}
{% endtabs %}

## Coding LLM

<mark style="color:orange;">`POST`</mark> `https://www.phoenix.global/sdk/computation/LLM/verticalLLM`

#### Headers

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| token<mark style="color:red;">\*</mark> | string | The token generated in the previous step |

#### Request Body

| Name                                     | Type   | Description                                                    |
| ---------------------------------------- | ------ | -------------------------------------------------------------- |
| prompt<mark style="color:red;">\*</mark> | string | Prompt                                                         |
| max\_new\_tokens                         | int    | The maximum number of tokens that can be consumed by this call |

#### Response

{% tabs %}
{% tab title="200: OK Return the result" %}

```json
{
    "code": 200,
    "msg": "success",
    "text": "Certainly! Below is an example of a simple Solidity smart contract that creates a basic token...",
    "tokens_balance": 1534425
}
```

{% endtab %}
{% endtabs %}

The usage of curl and golang sdk is as follows:

{% tabs %}
{% tab title="cURL" %}

```bash
curl --location 'https://www.phoenix.global/sdk/computation/LLM/verticalLLM' \
--header 'token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNzM4Mjh9.7Qy6jh5L1qvVVbOZYR3JrmWdothI2SCF-oGyC2BfZDs' \
--header 'Content-Type: application/json' \
--data '{
    "prompt": "Write a simple solidity contract"
}'
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
  "github.com/PhoenixGlobal/Phoenix-Computation-SDK/common"
  "github.com/PhoenixGlobal/Phoenix-Computation-SDK/controllers"
)

func main() {
  tokenStr := "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJFbWFpbCI6IjExMUBnbWFpbC5jb20iLCJleHAiOjE2NzgyNzM4Mjh9.7Qy6jh5L1qvVVbOZYR3JrmWdothI2SCF-oGyC2BfZDs"
  reqJSON := common.ReqLLM3{
    UserToken: tokenStr,
    Prompt:    "Write a simple solidity contract",
  }
  result, err := controllers.VerticalLLM(reqJSON)
  ...
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://computation-sdk.phoenix.global/reference/api-reference/phoenixllm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
