> ## Documentation Index
> Fetch the complete documentation index at: https://belajarkoding.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AI features

> Comprehensive documentation for AI features in KilatKoding, including provider setup, usage tracking, basic limits, and the most important custom areas.

<Info>
  The AI layer in KilatKoding provides a base for chat and generate flows. That base is enough to start from, but the final AI experience still depends heavily on the product logic you build on top of it.
</Info>

## What this feature includes

* `POST /api/ai/chat`
* `POST /api/ai/generate`
* provider selection
* usage tracking
* basic usage and plan limits

## Related routes and endpoints

| Route or endpoint       | Type          | Purpose                          |
| ----------------------- | ------------- | -------------------------------- |
| `POST /api/ai/chat`     | Streaming API | Streams AI chat responses        |
| `POST /api/ai/generate` | API mutation  | Handles one-shot text generation |

<Note>
  KilatKoding provides the core AI endpoints, but the screen route where users interact with AI is usually something you decide during product customization. In many implementations, these endpoints are called from a dashboard area or a custom app screen.
</Note>

## Main dependencies

| Item                                    | Required?           | Notes                                             |
| --------------------------------------- | ------------------- | ------------------------------------------------- |
| `NEXT_PUBLIC_ENABLE_AI=true`            | Yes                 | Enables the AI area                               |
| `AI_DEFAULT_PROVIDER`                   | Yes                 | `openai` or `anthropic`                           |
| `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` | Yes                 | Must match the chosen provider                    |
| Auth enabled                            | Depends on use case | Usually yes when AI is user-facing                |
| Payments enabled                        | Optional            | Needed if AI access is sold through subscriptions |

## What teams usually customize

* prompt design,
* chat or generation UX,
* output formatting,
* plan quota and limits,
* error handling for `429` and `503`,
* business guardrails and moderation logic.

## When this feature is disabled

It is usually disabled when:

* AI is not yet ready as a product layer,
* AI is only a roadmap idea and not mature enough,
* the team is not ready to manage provider costs and provider failure states.

## Verification checklist

1. The selected AI provider is really configured.
2. A test user can use chat or generate routes.
3. Usage limits and plan messaging are consistent.
4. The team understands `429` and `503` error behavior.
5. Pricing and plan benefits do not overpromise compared with real limits.

<Tip>
  If AI is core to your product, also review [Billing and payments](/en/kilatkoding/features/billing-and-payments) and [Operational runbook](/en/kilatkoding/operational-runbook).
</Tip>
