Getting started
Learn how to get started with the Anakin.ai API.
About requests to the API
This section describes the elements that make up an API request:
Every request to the API includes an HTTP method and a path. Depending on the API endpoint, you might also need to specify request headers, authentication information, query parameters, or body parameters.
The API reference documentation describes the HTTP method, path, and parameters for every endpoint. It also displays example requests and responses for each endpoint.
HTTP method
The HTTP method of an endpoint defines the type of action it performs on a given resource. Some common HTTP methods are GET
, POST
, DELETE
, and PATCH
. The API reference documentation provides the HTTP method for every endpoint.
For example, the HTTP method for the "Conversation with Chatbot" endpoint is POST
.
Path
Each endpoint has a path. The API reference documentation gives the path for every endpoint. For example, the path for the "Conversation with Chatbot" endpoint is /v1/apps/{appId}/chatbot/chat
.
The curly brackets {}
in a path denote path parameters that you need to specify. Path parameters modify the endpoint path and are required in your request. For example, the path parameter for the "Conversation with Chatbot" endpoint is {appId}
. To use this path in your API request, replace {appId}
with the name of the app ID where you would like to request.
Headers
Headers provide extra information about the request and the desired response. For an example of a request that uses headers, see "Making a request."
Authentication
The Anakin.ai API uses API access tokens for authentication. You can create API access tokens at a user account level. Each API access token provides access to all workspaces and all apps that user has been added to; access API Access Token Panel to view your available access tokens.
:::warning
Remember that your API access token is a secret! Treat your access token the same way you would treat your passwords or other sensitive credentials.
Do not share it with others or expose it in any client-side code (browsers, apps). Production requests must be routed through your own backend server where your API access token can be securely loaded from an environment variable or key management service.
:::
All API requests should include your API access token in an Authorization
HTTP header as follows:
Authorization: Bearer ANAKINAI_API_ACCESS_TOKEN
Parameters
Many API methods require or allow you to send additional information in parameters in your request. There are a few different types of parameters: Path parameters, body parameters, and query parameters.
Making a request
You can paste the command below into your terminal to run your first API request. Make sure to replace ANAKINAI_API_ACCESS_TOKEN with your secret API key.
curl https://api.anakin.ai/v1/apps/1344/chatbot/chat \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ANAKINAI_API_ACCESS_TOKEN" \
-d '{
"content": "Say this is a test!"
}'
This request queries the Chatbot#1344 with a prompt of "Say this is a test". You should get a response back that resembles the following:
{
"content": "This is a test!",
"threadId": "HHoxS5HW0XqQCAgbrSfDNKlilKQsnPLb"
}
Streaming
The Anakin.ai API provides the ability to stream responses back to a client in order to allow partial results for certain requests. To achieve this, we follow the Server-sent events standard.
Streaming is supported for both the Conversation with Chatbot API and the Run a Quick App API.