> ## 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.

# API quickstart

> Make your first project-scoped request to the Mibyan API

This guide takes you from a new Platform project to a verified API response. The API is OpenAI-compatible, but your key, project, limits, usage, and logs remain managed by Mibyan Platform.

## Before you start

You need:

* A Mibyan account.
* A project in [Mibyan Platform](https://platform.mibyanai.com).
* A project API key. The complete value is shown only once.
* A server-side environment where the key can be stored.

<Warning>
  Never place an API key in browser JavaScript, a mobile app bundle, a URL, a public repository, or a client-side log. Send requests through your own server.
</Warning>

## 1. Create a project key

Open **Platform → API keys**, choose the project, and create a key for the environment you need:

* `test` keys are for development and integration checks.
* `live` keys are for production traffic.

Use the narrowest permissions, model access, endpoint access, and expiry that fit the integration. Copy the secret immediately and save it in your secret manager.

## 2. Configure the client

The canonical API origin is `https://api.mibyanai.com`; SDKs should use `https://api.mibyanai.com/v1` as their base URL.

```bash theme={null}
export MIBYAN_API_KEY="mbn_test_..."
export MIBYAN_BASE_URL="https://api.mibyanai.com/v1"
```

## 3. Send a request

```bash theme={null}
curl "$MIBYAN_BASE_URL/chat/completions" \
  -H "Authorization: Bearer $MIBYAN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "mibyan-4.1",
    "messages": [
      {"role": "user", "content": "اكتب ملخصاً عملياً عن إطلاق منتج جديد."}
    ]
  }'
```

The response includes the Mibyan model ID and a `request_id` correlation value.

## 4. Verify the integration

Check the following before moving to production:

1. The request succeeds with the expected project key.
2. The response `model` is `mibyan-4.1`.
3. The request appears under the same project in **Usage** and **Logs**.
4. Invalid keys return `401` and disallowed endpoints return `403`.
5. Your server does not log the complete key or prompt content unnecessarily.

## Common first-request errors

| Status | Meaning                       | What to check                                                       |
| ------ | ----------------------------- | ------------------------------------------------------------------- |
| `400`  | Invalid request               | JSON, messages, token limits, and supported fields                  |
| `401`  | Authentication failed         | Bearer token, key status, expiry, and environment                   |
| `403`  | Permission denied             | Project, endpoint, model, or service-account policy                 |
| `404`  | Model or endpoint unavailable | Use the exact `/v1` path and the ID returned by `/models`           |
| `429`  | Rate or budget limit          | Response headers, project policy, and retry timing                  |
| `5xx`  | Temporary service issue       | Retry only according to [errors and retries](/api-reference/errors) |
