> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mibyanai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Use the API with Postman

> Configure Postman and send your first Mibyan Chat Completions request

You can test the Mibyan API from Postman without writing an application. You only need a project API key.

<Warning>
  Never expose an API key in a screenshot or public Collection. Store it as a secret or sensitive
  Postman environment variable instead of placing it directly in a saved request.
</Warning>

## Quick setup: import the OpenAPI definition

1. Open Postman and select **Import**.
2. Select **Link**.
3. Enter:

```text theme={null}
https://api.mibyanai.com/openapi.yaml
```

4. Select **Import** to create a Collection with the available endpoints.
5. Open `POST /v1/chat/completions` and configure its authorization as described below.

## Manual setup

### 1. Create an environment

Create a Postman environment named `Mibyan` with these variables:

| Variable          | Type    | Value                                                                |
| ----------------- | ------- | -------------------------------------------------------------------- |
| `MIBYAN_BASE_URL` | default | `https://api.mibyanai.com/v1`                                        |
| `MIBYAN_API_KEY`  | secret  | Your project key, normally beginning with `mbn_test_` or `mbn_live_` |

Save and select the environment.

### 2. Create the request

* Method: `POST`
* URL:

```text theme={null}
{{MIBYAN_BASE_URL}}/chat/completions
```

### 3. Configure authorization

Open **Authorization** and select:

* Type: `Bearer Token`
* Token: `{{MIBYAN_API_KEY}}`

Do not include the word `Bearer` in the Token field; Postman adds it automatically.

### 4. Add the header

| Key            | Value              |
| -------------- | ------------------ |
| `Content-Type` | `application/json` |

### 5. Add the JSON body

Select **Body → raw → JSON** and paste:

```json theme={null}
{
  "model": "mibyan-4.1",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "stream": false,
  "max_tokens": 64
}
```

Select **Send**. A successful response has this shape:

```json theme={null}
{
  "id": "chatcmpl_...",
  "object": "chat.completion",
  "model": "mibyan-4.1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello!",
        "refusal": null
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 206,
    "completion_tokens": 5,
    "total_tokens": 211
  }
}
```

Usage values are illustrative and vary by request and model.

## Test the Models endpoint

Create another request:

* Method: `GET`
* URL: `{{MIBYAN_BASE_URL}}/models`
* Authorization: the same Bearer Token

The public model `mibyan-4.1` should appear in `data`.

## Test streaming

Set `stream` to `true`. The response uses Server-Sent Events and ends with:

```text theme={null}
data: [DONE]
```

Start with `stream: false` to verify the URL, key, and JSON. Some Postman versions may display streamed events together in the response viewer instead of rendering each event immediately.

## Troubleshooting

| Status | Common cause                       | Resolution                                              |
| ------ | ---------------------------------- | ------------------------------------------------------- |
| `400`  | Invalid JSON or parameter          | Select JSON body mode and verify `model` and `messages` |
| `401`  | Missing or invalid key             | Check the environment and Bearer Token configuration    |
| `403`  | Key lacks endpoint or model access | Review the key permissions in Mibyan Platform           |
| `404`  | Incorrect URL or model             | Use `/v1/chat/completions` and `mibyan-4.1`             |
| `429`  | Rate or budget limit reached       | Review project Usage and limits, then retry later       |

Every response includes an `x-request-id` header. Keep it when contacting support, but never send your API key.
