> For the complete documentation index, see [llms.txt](https://docs.ai.neevcloud.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ai.neevcloud.com/tutorials/model-api/models/glm-5-2-model-api-tutorial.md).

# Run GLM-5.2 with the Model API

Deploying a large language model like [GLM-5.2](https://z.ai/blog/glm-5.2) traditionally requires provisioning GPU infrastructure, configuring an inference server, and managing scaling and uptime yourself. This adds setup time and operational overhead before you can send a single request.

[NeevCloud Model API](https://docs.ai.neevcloud.com/ai-inference/overview-1) removes this overhead by hosting GLM-5.2 as a production-ready endpoint. You connect to the model over a simple, OpenAI-compatible API without managing any underlying infrastructure.

This tutorial covers testing GLM-5.2 in the Model Playground, then connecting to the same model using the Model API to send your first inference request using cURL, Python, and JavaScript.

***

## Prerequisites

Before you begin, make sure you have:

* A NeevCloud account
* Terminal access
* cURL installed
* Python 3 installed
* Node.js and npm installed if you want to test using JavaScript

No infrastructure setup is required.

***

## Step 1: Log in to NeevCloud Dashboard

1. Open your browser and go to the [NeevCloud Console](https://console.ai.neevcloud.com/login).
2. Sign in with your credentials.

***

## Step 2: Test GLM-5.2 in Model Playground

From the left sidebar, navigate to **AI Inference → Model Playground**.

Under **Configuration**, from the **Select Model** dropdown, choose **GLM 5.2**.

You can adjust the following parameters before running your prompt:

* **Temperature** - Controls randomness in responses
* **Top-p Sampling**
* **Max Tokens** - Maximum length of the generated response

(Optional) Enter a system prompt in the **System Prompt** box, for example:

```
You are a helpful assistant.
```

In the **Prompt Editor** panel, enter your prompt, for example:

```
Explain the difference between a monolithic and a microservices architecture.
```

Click **Run Inference**.

The response appears in the **Output** panel, along with the tokens generated and time to first token (TTFT).

This helps you understand model behavior before integrating it into your application.

***

## Step 3: Open Model API

Once you have tested the model successfully, navigate to **AI Inference → Model API**.

Find the **GLM 5.2** card in the model catalogue. The right-hand panel shows model details and pay-per-token pricing.

Click **View Endpoint**.

***

## Step 4: Copy the API Endpoint

The **View Endpoint** panel opens, showing the **API Endpoint** field:

```
https://inference.ai.neevcloud.com/v1/chat/completions
```

Click the copy icon next to the field to copy the endpoint.

> **Note:** If you already have an API key from another model, you can reuse it here. Find it under **Security → API Keys**.

***

## Step 5: Generate an API Key

If you don't already have an API key:

1. In the **View Endpoint** panel, click **Create API Key**.
2. Copy your [API key](https://docs.ai.neevcloud.com/getting-started/create-api-key).
3. Save it securely.

For terminal-based testing, set the API key as an environment variable instead of putting the key directly into your code:

```bash
export NEEV_API_KEY="your-api-key-here"
```

Replace `your-api-key-here` with your NeevCloud API key.

***

## Step 6: Make Your First API Call

Once your API key is configured, you can send requests to GLM-5.2 using cURL, Python, or JavaScript.

<details>

<summary><strong>Option 1: cURL</strong></summary>

<br>

Send an inference request directly from your terminal:

```bash
curl --max-time 120 https://inference.ai.neevcloud.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $NEEV_API_KEY" \
  -d '{
    "model": "glm-5-2",
    "messages": [
      {
        "role": "user",
        "content": "Say hello in one short sentence."
      }
    ],
    "max_tokens": 2048
  }'
```

If the request is successful, the model-generated response is returned as JSON in your terminal.

A successful test returns a response similar to:

```json
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "message": {
        "content": "Hello there!",
        "role": "assistant"
      }
    }
  ]
}
```

The exact response content and other response fields may vary between requests.

</details>

<details>

<summary><strong>Option 2: Python</strong></summary>

<br>

Install the OpenAI Python SDK if you haven't already:

```bash
pip3 install openai
```

Create a Python file, such as `test_glm.py`:

```bash
nano test_glm.py
```

Add:

```python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["NEEV_API_KEY"],
    base_url="https://inference.ai.neevcloud.com/v1"
)

response = client.chat.completions.create(
    model="glm-5-2",
    messages=[
        {
            "role": "user",
            "content": "Say hello in one short sentence."
        }
    ],
    max_tokens=2048
)

print(response.choices[0].message.content)
```

Save the file and run:

```bash
python3 test_glm.py
```

If the request is successful, the model-generated response is printed directly in your terminal.

For example:

```
Hello there!
```

</details>

<details>

<summary><strong>Option 3: JavaScript</strong></summary>

<br>

Make sure Node.js is installed:

```bash
node --version
```

Install the OpenAI Node.js SDK:

```bash
npm install openai
```

Create a JavaScript file:

```bash
nano test_glm.js
```

Add:

```javascript
const OpenAI = require("openai");

const client = new OpenAI({
  apiKey: process.env.NEEV_API_KEY,
  baseURL: "https://inference.ai.neevcloud.com/v1"
});

async function main() {
  const response = await client.chat.completions.create({
    model: "glm-5-2",
    messages: [
      {
        role: "user",
        content: "Say hello in one short sentence."
      }
    ],
    max_tokens: 2048
  });

  console.log(response.choices[0].message.content);
}

main();
```

Run the JavaScript file:

```bash
node test_glm.js
```

If the request is successful, the model-generated response is printed in your terminal:

```
Hello there!
```

</details>

***

## Step 7: Verify the API Response

The cURL request returns a JSON response similar to:

<details>

<summary><strong>Full JSON response</strong></summary>

<br>

```json
{
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "message": {
        "content": "Hello there!",
        "role": "assistant"
      }
    }
  ],
  "created": 1785476731,
  "id": "chatcmpl-84f3dc06-5dea-4435-aa82-1dbc9ff9790a",
  "model": "zai-org/GLM-5.2",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 216,
    "prompt_tokens": 19,
    "total_tokens": 235
  }
}
```

</details>

The exact response content, ID, timestamps, and token counts will vary for each request.

In this response:

| Field                        | Description                                                                                                                                               |
| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `choices[0].message.content` | Contains the model-generated response.                                                                                                                    |
| `choices[0].finish_reason`   | Indicates why generation stopped. `"stop"` means the model completed its response normally. `"length"` means the response reached the `max_tokens` limit. |
| `model`                      | Shows the underlying model that served the request. It returns as `zai-org/GLM-5.2`, even though you request it using the model ID `glm-5-2`.             |
| `usage.prompt_tokens`        | Number of input tokens processed.                                                                                                                         |
| `usage.completion_tokens`    | Number of output tokens generated.                                                                                                                        |
| `usage.total_tokens`         | Total input and output tokens processed.                                                                                                                  |

A successful response with `"finish_reason": "stop"` and generated content confirms that your inference request was processed successfully.

You have now successfully tested GLM-5.2 using the NeevCloud Model API with cURL, Python, and JavaScript.

***

## Conclusion

You have successfully tested GLM-5.2, generated and configured an API key, and made inference requests using cURL, Python, and JavaScript.

For more details, explore the Model API documentation in [NeevCloud Documentation](https://docs.ai.neevcloud.com/).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ai.neevcloud.com/tutorials/model-api/models/glm-5-2-model-api-tutorial.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
