Skip to main content
POST
/
assistants
Create Assistant
curl --request POST \
  --url https://api.example.com/assistants \
  --header 'Content-Type: application/json' \
  --data '
{
  "graph_id": "<string>",
  "assistant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "config": {},
  "context": {},
  "metadata": {},
  "if_exists": "raise",
  "name": "<string>",
  "description": "<string>"
}
'
import requests

url = "https://api.example.com/assistants"

payload = {
    "graph_id": "<string>",
    "assistant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
    "config": {},
    "context": {},
    "metadata": {},
    "if_exists": "raise",
    "name": "<string>",
    "description": "<string>"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    graph_id: '<string>',
    assistant_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    config: {},
    context: {},
    metadata: {},
    if_exists: 'raise',
    name: '<string>',
    description: '<string>'
  })
};

fetch('https://api.example.com/assistants', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.example.com/assistants",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'graph_id' => '<string>',
    'assistant_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
    'config' => [
        
    ],
    'context' => [
        
    ],
    'metadata' => [
        
    ],
    'if_exists' => 'raise',
    'name' => '<string>',
    'description' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.example.com/assistants"

	payload := strings.NewReader("{\n  \"graph_id\": \"<string>\",\n  \"assistant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n  \"config\": {},\n  \"context\": {},\n  \"metadata\": {},\n  \"if_exists\": \"raise\",\n  \"name\": \"<string>\",\n  \"description\": \"<string>\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.example.com/assistants")
  .header("Content-Type", "application/json")
  .body("{\n  \"graph_id\": \"<string>\",\n  \"assistant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n  \"config\": {},\n  \"context\": {},\n  \"metadata\": {},\n  \"if_exists\": \"raise\",\n  \"name\": \"<string>\",\n  \"description\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.example.com/assistants")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"graph_id\": \"<string>\",\n  \"assistant_id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n  \"config\": {},\n  \"context\": {},\n  \"metadata\": {},\n  \"if_exists\": \"raise\",\n  \"name\": \"<string>\",\n  \"description\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "assistant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "graph_id": "<string>",
  "config": {
    "tags": [
      "<string>"
    ],
    "recursion_limit": 123,
    "configurable": {}
  },
  "created_at": "2023-11-07T05:31:56Z",
  "updated_at": "2023-11-07T05:31:56Z",
  "metadata": {},
  "context": {},
  "version": 123,
  "name": "<string>",
  "description": "<string>"
}
{
  "detail": "<string>"
}
{
  "detail": "<string>"
}
{
  "detail": "<string>"
}

Body

application/json

Payload for creating an assistant.

graph_id
string
required

The ID of the graph the assistant should use. The graph ID is normally set in your langgraph.json configuration.

assistant_id
string<uuid>

The ID of the assistant. If not provided, a random UUID will be generated.

config
Config · object

Configuration to use for the graph. Useful when graph is configurable and you want to create different assistants based on different configurations.

context
Context · object

Static context added to the assistant.

metadata
Metadata · object

Metadata to add to assistant.

if_exists
enum<string>
default:raise

How to handle duplicate creation. Must be either 'raise' (raise error if duplicate), or 'do_nothing' (return existing assistant).

Available options:
raise,
do_nothing
name
string

The name of the assistant. Defaults to 'Untitled'.

description
string | null

The description of the assistant. Defaults to null.

Response

Success

assistant_id
string<uuid>
required

The ID of the assistant.

graph_id
string
required

The ID of the graph.

config
Config · object
required

The assistant config.

created_at
string<date-time>
required

The time the assistant was created.

updated_at
string<date-time>
required

The last time the assistant was updated.

metadata
Metadata · object
required

The assistant metadata.

context
Context · object

Static context added to the assistant.

version
integer

The version of the assistant

name
string

The name of the assistant

description
string | null

The description of the assistant