> For the complete documentation index, see [llms.txt](https://docs.kodesage.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kodesage.ai/api/quickstart.md).

# Quickstart

Use the Kodesage Chat API to embed AI-powered chats in your app, enriched with your codebase and project data for smart assistance.

The Kodesage Chat API provides an OpenAI like endpoint for AI-powered conversations enriched with your project's knowledge base. This allows you to integrate intelligent code assistance into your own applications.

**Getting your project ID**

You can find your Project ID in the Kodesage web interface URL when viewing a project.

Example:

When you navigate to your project's chat page, the URL will look like:

```
https://localhost/project/01K5BQSXND0N595C18DJMVN4VA/chat
```

The Project ID is: **01K5BQSXND0N595C18DJMVN4VA**

**Athentication**

<sup>**API Token Configuration**</sup>

The API uses Bearer token authentication. The API token must be configured during deployment by your system administrator.

<sup>**Environment Variable:**</sup>

```
KODESAGE_API_TOKEN=your-secure-token-here
```

<sup>**Using the Token**</sup>

Include the token in the Authorization header of every request:

```
Authorization: Bearer your-secure-token-here
```

**API Endpoints**

<sup>**Chat Completions Endpoint**</sup>

```
POST /api/projects/{project_id}/v1/chat/completions
```

<sup>**Paramaters**</sup>

{project\_id} - Your project identifier (e.g., 01K5BQSXND0N595C18DJMVN4VA)

<sup>**Request Format**</sup>

```
Content-Type: application/json
Authorization: Bearer YOUR API_TOKEN
```

<sup>**Request Body**</sup>

```
{
    "messages": [
        {
            "role": "user",
            "content": "Your question here"
        }
    ]
}
```

<sup>**Message Roles**</sup>

* **user** - Messages from the end user
* **assistant** - Previous responses from the AI (for conversation history)

<sup>**Multi-turn Conversations**</sup>

To maintain conversation context, include the full conversation history:

<pre><code>{
    "messages": [
        {
            "role": "user",
            "content": "How does authentication work in this project?"
        },
        {
            "role": "assistant",
            "content": "The project uses Spring Security with..."
        },
        {
<strong>            "role": "user",
</strong>            "content": "Can you show me the code for that?"
        }
    ]
}
</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.kodesage.ai/api/quickstart.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
