# Quickstart

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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
