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

# Create chat

> Yeni bir sohbet oturumu oluşturun ve yapay zeka ile geliştirmeye başlayın

Yeni bir sohbet oturumu oluşturur ve yapay zeka işlemini başlatır.

## İstek

```
POST /api/chat
```

### Başlıklar

| Header | Zorunlu | Açıklama |
| - | - | - |
| `Authorization` | Evet | `Bearer macaly_...` |
| `Content-Type` | Evet | `application/json` |

### İstek gövdesi parametreleri

| Alan | Tür | Zorunlu | Varsayılan | Açıklama |
| - | - | - | - | - |
| `content` | string | Evet | - | Kullanıcının mesajı veya istemi |
| `stream` | boolean | Hayır | `true` | `false` ise stream yerine JSON döndürür |
| `backend` | string | Hayır | `"DEFAULT"` | Kullanılacak arka uç |
| `executionMode` | `"auto"` \| `"planning"` \| `"build"` | Hayır | - | Yapay zekanın göreve nasıl yaklaşacağını belirler |
| `model` | `"gpt-5.6-terra"` \| `"gpt-6.1-sol"` \| `"gpt-6-luna"` \| `"grok-4-6"` \| `"kimi-k3"` \| `"sonnet-5-5"` \| `"opus-5-5"` \| `"blueai-glm-5-3"` \| `"blueai-glm-5-3-flash"` | Hayır | - | Kullanılacak yapay zeka modeli. Varsayılan olarak ekip için yapılandırılmış model kullanılır |
| `reasoningEffort` | `"medium"` \| `"high"` | Hayır | - | Yapay zekanın görev üzerinde ne kadar derin düşüneceğini belirler |
| `experimental_attachments` | array | Hayır | `[]` | Dosya ekleri (format için aşağıya bakın) |

#### Ek formatı

`experimental_attachments` dizisindeki her öğe aşağıdaki yapıya sahiptir:

| Alan | Tür | Zorunlu | Açıklama |
| - | - | - | - |
| `url` | string | Evet | Eklenecek dosyanın URL'si |
| `name` | string | Hayır | Ek için görüntülenecek ad |
| `contentType` | string | Hayır | Dosyanın MIME türü |

### Örnek istek

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://www.macaly.com/api/chat \
    -H "Authorization: Bearer macaly_abc123..." \
    -H "Content-Type: application/json" \
    -d '{
      "content": "Create a landing page for a coffee shop",
      "stream": false
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://www.macaly.com/api/chat', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer macaly_abc123...',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      content: 'Create a landing page for a coffee shop',
      stream: false,
    }),
  });

  const data = await response.json();
  console.log(data.chatId);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://www.macaly.com/api/chat',
      headers={
          'Authorization': 'Bearer macaly_abc123...',
          'Content-Type': 'application/json',
      },
      json={
          'content': 'Create a landing page for a coffee shop',
          'stream': False,
      },
  )

  data = response.json()
  print(data['chatId'])
  ```
</CodeGroup>

## Yanıt

### JSON yanıtı (`stream: false` olduğunda)

```json theme={null}
{
  "chatId": "abc123def456",
  "url": "https://www.macaly.com/chat/abc123def456",
  "streamId": "stream_xyz789",
  "assistantMessageId": "msg_123"
}
```

| Alan | Tür | Açıklama |
| - | - | - |
| `chatId` | string | Sohbetin benzersiz kimliği |
| `url` | string | Sohbeti görüntülemek için doğrudan URL |
| `streamId` | string \| undefined | Abone olmak için kullanılan stream kimliği. Yalnızca işlem tabanlı arka uçlarda bulunur |
| `assistantMessageId` | string \| undefined | Oluşturulmakta olan asistan mesajının kimliği. Yalnızca işlem tabanlı arka uçlarda bulunur |

### Stream yanıtı (`stream: true`, varsayılan)

Stream etkinleştirildiğinde yanıt bir metin stream'i olur:

```
2:[{"chatId":"abc123def456"}]
0:"Starting to build..."
...
```

İlk satır, sohbet kimliğini `2:[{"chatId":"..."}]` formatında içerir.

#### Sohbet kimliğini stream'den ayrıştırma

```javascript theme={null}
const text = await response.text();
const match = text.match(/2:\[{"chatId":"([^"]+)"/);
const chatId = match?.[1];
```

## Durum kodları

| Durum | Açıklama |
| - | - |
| 200 | Başarılı - Sohbet oluşturuldu |
| 400 | Geçersiz istek gövdesi |
| 401 | Geçersiz veya eksik API anahtarı |
| 402 | Yetersiz kredi |
| 403 | Erişim reddedildi - Belirtilen ekip için yetkiniz yok |
| 422 | Doğrulama hatası |
| 429 | İstek limiti aşıldı |
| 500 | Sunucu hatası |

## Sonraki adımlar

Bir sohbet oluşturduktan sonra:

1. **İlerlemeyi takip edin** - [`GET /api/chat/{chatId}/status`](/docs/tr/api/get-status)
2. **Stream'e abone olun** - Gerçek zamanlı güncellemeler için [`GET /api/chat/{chatId}/subscribe`](/docs/tr/api/subscribe-stream)
3. **Takip mesajları gönderin** - [`POST /api/chat/{chatId}/publish`](/docs/tr/api/publish-message)


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