# Quickstart

Page: https://docs.sonecentral.com/en/hizli-baslangic
Markdown: https://docs.sonecentral.com/en/hizli-baslangic.md

> Create a key, find your assistant's ID and send your first message.

> **Give the docs to your agent.** The full documentation is one Markdown file: https://docs.sonecentral.com/en/llms-full.txt. Paste this URL into your coding agent. For one page, use its .md address, for example https://docs.sonecentral.com/en/hizli-baslangic.md. Page index: https://docs.sonecentral.com/en/llms.txt

Working with a coding agent? Give it the URL above and describe what you want to build. To implement it yourself, follow these four steps.

### Create a key

In Sonecentral, open **Metin asistanı** (Text assistant) and create a key under **API anahtarları** (API keys). Only workspace administrators see this section. **Tür** (Type) offers two choices:

- **Server key** starts with `sk-sone-v1-` and belongs in your backend. Never put it in a browser, mobile app bundle or public repository.
- **Publishable key** starts with `pk-sone-v1-` and is for your website's chat widget. It works only from your allowed origins.

The key is shown once, when created. Save it immediately as an environment variable:

```bash
export SONE_API_KEY="sk-sone-v1-..."
```

Details: [Authentication and keys](https://docs.sonecentral.com/en/kimlik-dogrulama.md).

### Find your assistant's ID

```bash
curl https://pb.sonecentral.com/api/v1/models \
  -H "Authorization: Bearer $SONE_API_KEY"
```

Use the listed `id` as `model`. If the key allows only one assistant, `"default"` is sufficient.

### Send the first message

**curl**

```bash
curl https://pb.sonecentral.com/api/v1/chat/completions \
  -H "Authorization: Bearer $SONE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "default",
    "messages": [
      { "role": "user", "content": "Can I book an appointment tomorrow afternoon?" }
    ]
  }'
```

**OpenAI JS**

```ts
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://pb.sonecentral.com/api/v1',
  apiKey: process.env.SONE_API_KEY,
});

const completion = await client.chat.completions.create({
  model: 'default',
  messages: [{ role: 'user', content: 'Can I book an appointment tomorrow afternoon?' }],
});

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

**OpenAI Python**

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://pb.sonecentral.com/api/v1",
    api_key=os.environ["SONE_API_KEY"],
)

completion = client.chat.completions.create(
    model="default",
    messages=[{"role": "user", "content": "Can I book an appointment tomorrow afternoon?"}],
)

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

**Vercel AI SDK**

```ts
import { createOpenAI } from '@ai-sdk/openai';
import { generateText } from 'ai';

const sone = createOpenAI({
  baseURL: 'https://pb.sonecentral.com/api/v1',
  apiKey: process.env.SONE_API_KEY,
});

const { text } = await generateText({
  model: sone.chat('default'),
  prompt: 'Can I book an appointment tomorrow afternoon?',
});

console.log(text);
```

Install with `npm i openai`, `pip install openai` or `npm i ai @ai-sdk/openai`. Examples were tested with `openai` 7 (Node), `openai` 2 (Python), `ai` 7 and `@ai-sdk/openai` 4.

### Continue the conversation

The response includes `choices[0].message.sone.conversation_id`. Send it back in `metadata` on the next request so the assistant remembers earlier messages. When sending only the new message, add an `Idempotency-Key` to each message: retrying after a network failure with the same key prevents duplicate storage.

```ts
// OpenAI types omit `sone`; see the Chat Completions page for its type.
const { sone } = completion.choices[0].message as unknown as {
  sone: { conversation_id: string };
};

await client.chat.completions.create(
  {
    model: 'default',
    metadata: { conversation_id: sone.conversation_id },
    messages: [{ role: 'user', content: 'Is four oclock available?' }],
  },
  { headers: { 'Idempotency-Key': crypto.randomUUID() } },
);
```

Other continuation methods, retries and browser persistence: [Conversation continuity](https://docs.sonecentral.com/en/sohbet-surekliligi.md).

## Where to go next

- Add a chat to your website: [Embedded chat widget](https://docs.sonecentral.com/en/sohbet-penceresi.md)
- React and Next.js: [Vercel AI SDK](https://docs.sonecentral.com/en/vercel-ai-sdk.md)
- Product cards and buttons: [Rich messages](https://docs.sonecentral.com/en/zengin-mesajlar.md)
