# Quickstart
Source: https://docs.mserve.ai/docs/quickstart
Summary: Your first chat completion with the official OpenAI SDK. Change the base URL and the key. Nothing else.
Availability: available
Last reviewed: 2026-08-25

### Install the SDK

Use the official OpenAI SDK for your language.

**Python**

```bash
pip install openai
```

**JavaScript**

```bash
npm install openai
```

### Set your API key

Keys look like `ms_live_` followed by 40 characters. Put the key in your environment. Never commit it.

```bash
export MSERVE_API_KEY="ms_live_your_key"
```

> **Check the key**
> `GET /mserve/v1/key` returns the key's label, limits, usage today and this month, and the account balance. See [Authentication](/docs/resources/authentication#inspect-a-key).

### Create a chat completion

Point the SDK at `https://api.mserve.ai/openai/v1` and request the `qwen3.8-27b` model.

**Python**

```python
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.mserve.ai/openai/v1", api_key=os.environ["MSERVE_API_KEY"])

response = client.chat.completions.create(
    model="qwen3.8-27b",
    messages=[{"role": "user", "content": "Write one sentence about GPUs."}],
)
print(response.choices[0].message.content)
```

**JavaScript**

```ts
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.mserve.ai/openai/v1", apiKey: process.env.MSERVE_API_KEY });

const response = await client.chat.completions.create({
  model: "qwen3.8-27b",
  messages: [{ role: "user", content: "Write one sentence about GPUs." }],
});
console.log(response.choices[0].message.content);
```

**cURL**

```bash
curl https://api.mserve.ai/openai/v1/chat/completions \
  -H "Authorization: Bearer $MSERVE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen3.8-27b",
    "messages": [{"role": "user", "content": "Write one sentence about GPUs."}]
  }'
```

### Read the response

The response is the OpenAI chat completion object. `model` echoes the id you sent. `usage` counts prompt and completion tokens, and those are what you are billed for.

```json
{
  "id": "chatcmpl-8f1c…",
  "object": "chat.completion",
  "model": "qwen3.8-27b",
  "choices": [
    { "index": 0, "message": { "role": "assistant", "content": "GPUs run thousands of small calculations at once." }, "finish_reason": "stop" }
  ],
  "usage": { "prompt_tokens": 14, "completion_tokens": 11, "total_tokens": 25 }
}
```

## Next steps

- [Migrate an existing app](/docs#let-your-agent-make-the-switch): Copy the prompt and let your coding agent change the base URLs and model ids.

- [Speak the answer](/docs/voice/text-to-speech): Send the text to /openai/v1/audio/speech and stream the audio.

- [Stream tokens](/docs/inference/realtime#stream-tokens): Server-sent events with usage on the final chunk.

- [Compatibility](/docs/resources/compatibility): Which parameters reach the model and which return 400.
