POST
/
v0
/
chat_sessions
/
chat_results
import { InkeepAI } from "@inkeep/ai-api";

async function run() {
  const sdk = new InkeepAI({
    apiKey: "<INKEEP_API_KEY>",
  });

  const result = await sdk.chatSession.create({
    integrationId: "<INKEEP_INTEGRATION_ID>",
    chatSession: {
      messages: [
        {
          role: "user",
          content: "How do I get started?",
        },
      ],
    },
    stream: true,
  });

  /* Example of handling a streamed response */
  if (res.chatResultStream == null) {
    throw new Error("failed to create stream: received null value");
  }

  let chatSessionId: string | undefined | null = undefined;

  for await (const event of res.chatResultStream) {
    if (event.event == "message_chunk") {
      console.log("Partial message: " + event.data.contentChunk);
      chatSessionId = event.data.chatSessionId;
    }
    if (event.event == "records_cited") {
      console.log("Citations: ", JSON.stringify(event.data.citations, null, 2));
    }
  }
}

run();
{
  "chat_session_id": "<string>",
  "message": {
    "role": "<string>",
    "content": "<string>",
    "records_cited": {
      "citations": [
        {
          "number": 123,
          "record": {
            "type": "documentation",
            "url": "<string>",
            "title": "<string>",
            "description": "<string>",
            "breadcrumbs": [
              "<string>"
            ]
          },
          "hit_url": "<string>"
        }
      ]
    }
  }
}

Authorizations

Authorization
string
headerrequired

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
integration_id
string
required
chat_session
object
required
chat_mode
Available options:
turbo,
auto
stream
boolean
default: false

Response

200 - application/json
chat_session_id
string
required
message
object
required