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

API Token Configuration

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

Environment Variable:

KODESAGE_API_TOKEN=your-secure-token-here

Using the Token

Include the token in the Authorization header of every request:

Authorization: Bearer your-secure-token-here

API Endpoints

Chat Completions Endpoint

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

Paramaters

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

Request Format

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

Request Body

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

Message Roles

  • user - Messages from the end user

  • assistant - Previous responses from the AI (for conversation history)

Multi-turn Conversations

To maintain conversation context, include the full conversation history:

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

Last updated