Skip to content
On this page

Getting started

To interact with the Gigachat API, it is necessary to authenticate your requests by creating and providing a secret API key. You can create your key by visiting the API keys page. Once you have your key, authenticate your requests to Gigachat's API by placing it in the Authorization request's header.

Authorization: Bearer <API_KEY>

Test your API key by making a request to the https://api.gigachat.ai/chatbots endpoint. You should get a 200 response and a response body of a empty array [].

shell
curl 'https://api.gigachat.ai/chatbots' \
  -H 'Authorization: Bearer {API_token}'

Create a chatbot

Now that you can authenticate with the Gigachat API, create your first chatbot.

shell
curl --request POST \
  --url https://api.gigachat.ai/chatbots \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <API_KEY>' \
  --data '{
	"name": "Superbot"
}'

To view all available chatbot properties, see the chatbot schema.

Train your chatbot

Your chatbot can only be as smart as the content it has access to. As the foremost expert on your data, you determine the content to push to Gigachat.

We provide the flexibility for you to push virtually any type of content, provided that it's translated into text format. Whether it's the informative content from your website, intricate details of your product, or the extensive knowledge from your company's database.

shell
curl --request POST \
  --url https://api.gigachat.ai/chatbots/{chatbot_id}/documents \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <API_KEY>' \
  --data '{
	"name": "https://cloudflare.com/workers",
	"content": "This is a sample document"
}'

Start a conversation

Congratulation! You have successfully created an AI chatbot, start a conversation with it by asking a question related to your content.

shell
curl --request POST \
  --url https://api.gigachat.ai/chatbots/{chatbot_id}/conversations \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer <API_KEY>' \
  --data '{
	"conversation_id": "12345",
	"user_id": "[email protected]",
	"prompt": "Hello"
}'

Response Content-Type: text/event-stream; charset=utf-8

To see all available properties, see the conversation schema

Next steps