# API Quickstart Guide

Validate the integration path quickly. Most teams only need to change the base URL and API key.

> 2-minute setup

## Step 1: Get Your API Key

1. Sign up for DevToks and create your account
2. Go to Dashboard -> API Keys -> Create New Key
3. Copy your key (starts with sk-)

## Step 2: Make Your First Request

Choose a language below.

### cURL

```bash
curl https://api.devtoks.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-your-key" \
  -d '{
    "model": "gpt-4.1",
    "messages": [
      {"role": "user", "content": "Hello! What models do you support?"}
    ]
  }'
```

### Python (OpenAI SDK)

```bash
pip install openai
```

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.devtoks.com/v1",
    api_key="sk-your-key",
)

response = client.chat.completions.create(
    model="gpt-4.1",
    messages=[
        {"role": "user", "content": "Hello! What models do you support?"}
    ],
)

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

### TypeScript (OpenAI SDK)

```bash
npm install openai
```

```typescript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.devtoks.com/v1",
  apiKey: "sk-your-key",
});

const response = await client.chat.completions.create({
  model: "gpt-4.1",
  messages: [
    { role: "user", content: "Hello! What models do you support?" },
  ],
});

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

## Step 3: Streaming Responses

Enable real-time token streaming.

```python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.devtoks.com/v1",
    api_key="sk-your-key",
)

stream = client.chat.completions.create(
    model="claude-sonnet-4-20250514",
    messages=[{"role": "user", "content": "Write a short poem about APIs"}],
    stream=True,
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")
```

## Step 4: List Available Models

See the models available to your key.

```bash
curl https://api.devtoks.com/v1/models \
  -H "Authorization: Bearer sk-your-key"
```

## Step 5: Check Balance

Confirm the account balance, this key's quota, and the currently available balance for this key.

```bash
curl https://api.devtoks.com/v1/token/balance \
  -H "Authorization: Bearer sk-your-key"
```

- `data.account.quota`: account balance
- `data.api_key.remain_quota`: this API key's quota
- `data.effective.available_quota`: currently available balance for this key

## What's Next?

- [API Reference](https://devtoks.com/docs/api-reference): Full endpoint documentation
- [Claude Code Setup](https://devtoks.com/tutorials/claude-code): Use with Claude Code
- [Cursor Setup](https://devtoks.com/tutorials/cursor): Use with Cursor IDE
- [Dashboard](https://devtoks.com/dashboard): Monitor usage and billing
