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

# Introduction

> Make your first NanoGPT API request with the OpenAI SDK.

## Your first request

Install the official Python SDK with `pip install openai`, create an [API key](https://nano-gpt.com/api) and set it as `NANOGPT_API_KEY` in your environment. Keep the key on your server, outside source control. Pick the example for how you pay.

Use the exact SDK base URL `https://api.nano-gpt.com/api/v1`. The SDK appends `/chat/completions`, producing `POST /api/v1/chat/completions`. Do not append that endpoint to `base_url` yourself.

### Use my Pro allowance

Set the key's **Billing mode** to **Subscription only** (on the API page, in the key's options). Requests then count against your Pro allowance and never use balance. This example uses GLM 5.3, which Pro includes at 1×. [`GET /api/subscription/v1/models`](https://docs.nano-gpt.com/api-reference/endpoint/models) lists every model Pro includes.

```python theme={null}
import os
from openai import OpenAI

with OpenAI(
    api_key=os.environ["NANOGPT_API_KEY"],
    base_url="https://api.nano-gpt.com/api/v1",
    timeout=60.0,
    max_retries=0,
) as client:
    response = client.chat.completions.create(
        model="z-ai/glm-5.3",
        messages=[{"role": "user", "content": "Say hello in one sentence."}],
    )
    print("Request ID:", response._request_id)
    print(response.choices[0].message.content)
```

### Use my balance

Add [balance](https://nano-gpt.com/balance) and use a key whose billing mode is not Subscription only (a Subscription only key refuses balance requests). `billing_mode: "paygo"` bills the request to balance, even if you also have Pro.

```python theme={null}
import os
from openai import OpenAI

with OpenAI(
    api_key=os.environ["NANOGPT_API_KEY"],
    base_url="https://api.nano-gpt.com/api/v1",
    timeout=60.0,
    max_retries=0,
) as client:
    response = client.chat.completions.create(
        model="openai/gpt-6.1-sol",
        messages=[{"role": "user", "content": "Say hello in one sentence."}],
        extra_body={"billing_mode": "paygo"},
    )
    print("Request ID:", response._request_id)
    print(response.choices[0].message.content)
```

The request ID helps support find a failed request. Save it with your application logs. For streaming, errors, usage and tool calls, copy the tested [Quickstart](https://docs.nano-gpt.com/quickstart.md) example.

## Explore the API

* [Chat Completions](https://docs.nano-gpt.com/api-reference/endpoint/chat-completion.md): `POST /api/v1/chat/completions`
* [Responses](https://docs.nano-gpt.com/api-reference/endpoint/responses.md): `POST /api/v1/responses`
* [Messages](https://docs.nano-gpt.com/api-reference/endpoint/messages.md): `POST /api/v1/messages`
* [Image generation](https://docs.nano-gpt.com/api-reference/image-generation.md): `POST /api/v1/images/generations`
* [Video generation](https://docs.nano-gpt.com/api-reference/video-generation.md): job submission and polling
* [API Hosts](https://docs.nano-gpt.com/api-reference/miscellaneous/api-hosts.md): direct API host, partner domains and runtime limits
* [Private Mode](https://docs.nano-gpt.com/api-reference/miscellaneous/private-mode.md): local encryption proxy

For selected endpoints, you can also use [Accountless Lightning L402 API Payments](https://docs.nano-gpt.com/api-reference/miscellaneous/x402.md) to receive a payment quote without an account or API key by including `x-x402: true` on the initial unauthenticated quote request. All x402 rails, including XNO, were removed on 2026-11-20; the header and API paths retain historical names for Lightning L402. Check `GET /api/v1/x402/endpoints` for the current supported matrix.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.