square-terminalImplementation Examples

See real-world implementation examples for the Kodesage Chat API including sample code in multiple languages and integration patterns.

Example 1: Simple question

Request:

curl -X POST "https://your-kodesage-instance.com/api/projects/01K5BQSXND0N595C18DJMVN4VA/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
    "messages": [
      {
        "role": "user",
        "content": "How is user authentication implemented?"
      }
  ]
}'

Response:

{
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "According to WebSecurityConfig.java, the project uses Spring Security with a custom CosmossAuthenticationProvider..."
         }
      }
   ]
}

Example 2: Multi-turn conversation

Request:

The API is compatible with official OpenAI client libraries. This means you can use standard OpenAI SDKs with just a custom base URL.

Quick Start (Python and C#)

Below you will find minimal working examples for both Python and C# using the official OpenAI SDKs.

Python example

C# (.NET) Example

Error handling

Error Response Format

All errors return a JSON object with an error field:

Last updated