Create Client Token
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expiresIn: 123,
allowedModels: ['<string>'],
allowedOrigins: ['<string>'],
constraints: {realtime: {maxSessionDuration: 123}},
metadata: {}
})
};
fetch('https://api.decart.ai/v1/client/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.decart.ai/v1/client/tokens"
payload = {
"expiresIn": 123,
"allowedModels": ["<string>"],
"allowedOrigins": ["<string>"],
"constraints": { "realtime": { "maxSessionDuration": 123 } },
"metadata": {}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://api.decart.ai/v1/client/tokens")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"expiresIn\": 123,\n \"allowedModels\": [\n \"<string>\"\n ],\n \"allowedOrigins\": [\n \"<string>\"\n ],\n \"constraints\": {\n \"realtime\": {\n \"maxSessionDuration\": 123\n }\n },\n \"metadata\": {}\n}")
.asString();val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"expiresIn\": 123,\n \"allowedModels\": [\n \"<string>\"\n ],\n \"allowedOrigins\": [\n \"<string>\"\n ],\n \"constraints\": {\n \"realtime\": {\n \"maxSessionDuration\": 123\n }\n },\n \"metadata\": {}\n}")
val request = Request.Builder()
.url("https://api.decart.ai/v1/client/tokens")
.post(body)
.addHeader("x-api-key", "<api-key>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()import Foundation
let parameters = [
"expiresIn": 123,
"allowedModels": ["<string>"],
"allowedOrigins": ["<string>"],
"constraints": ["realtime": ["maxSessionDuration": 123]],
"metadata": []
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.decart.ai/v1/client/tokens")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"x-api-key": "<api-key>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))curl --request POST \
--url https://api.decart.ai/v1/client/tokens \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"expiresIn": 123,
"allowedModels": [
"<string>"
],
"allowedOrigins": [
"<string>"
],
"constraints": {
"realtime": {
"maxSessionDuration": 123
}
},
"metadata": {}
}
'{
"apiKey": "<string>",
"expiresAt": "<string>",
"permissions": {},
"constraints": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authentication
Create Client Token
Create an ephemeral API token for client sessions.
POST
/
v1
/
client
/
tokens
Create Client Token
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expiresIn: 123,
allowedModels: ['<string>'],
allowedOrigins: ['<string>'],
constraints: {realtime: {maxSessionDuration: 123}},
metadata: {}
})
};
fetch('https://api.decart.ai/v1/client/tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.decart.ai/v1/client/tokens"
payload = {
"expiresIn": 123,
"allowedModels": ["<string>"],
"allowedOrigins": ["<string>"],
"constraints": { "realtime": { "maxSessionDuration": 123 } },
"metadata": {}
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)HttpResponse<String> response = Unirest.post("https://api.decart.ai/v1/client/tokens")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"expiresIn\": 123,\n \"allowedModels\": [\n \"<string>\"\n ],\n \"allowedOrigins\": [\n \"<string>\"\n ],\n \"constraints\": {\n \"realtime\": {\n \"maxSessionDuration\": 123\n }\n },\n \"metadata\": {}\n}")
.asString();val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"expiresIn\": 123,\n \"allowedModels\": [\n \"<string>\"\n ],\n \"allowedOrigins\": [\n \"<string>\"\n ],\n \"constraints\": {\n \"realtime\": {\n \"maxSessionDuration\": 123\n }\n },\n \"metadata\": {}\n}")
val request = Request.Builder()
.url("https://api.decart.ai/v1/client/tokens")
.post(body)
.addHeader("x-api-key", "<api-key>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute()import Foundation
let parameters = [
"expiresIn": 123,
"allowedModels": ["<string>"],
"allowedOrigins": ["<string>"],
"constraints": ["realtime": ["maxSessionDuration": 123]],
"metadata": []
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.decart.ai/v1/client/tokens")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"x-api-key": "<api-key>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))curl --request POST \
--url https://api.decart.ai/v1/client/tokens \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"expiresIn": 123,
"allowedModels": [
"<string>"
],
"allowedOrigins": [
"<string>"
],
"constraints": {
"realtime": {
"maxSessionDuration": 123
}
},
"metadata": {}
}
'{
"apiKey": "<string>",
"expiresAt": "<string>",
"permissions": {},
"constraints": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Headers
API key for authentication
Body
application/json
Seconds until the token expires (default 60)
Restrict which models this token can access (max 20)
Restrict which web origins this token can be used from (max 20)
Operational limits for the token
Show child attributes
Show child attributes
Was this page helpful?
⌘I