Create Model Session
Create a session with a provider using a model ID and associate it with the API key. This endpoint creates a session and automatically associates it with the API key used for authentication. Each API key can have at most one active session at a time.
Authorization
AuthorizationRequiredBearer <token>🚀 OAuth2 authentication via secure identity provider
In: header
Scope: openid, email, profile
AuthorizationRequiredBearer <token>🎫 JWT Bearer token from OAuth2 login or direct token
In: header
Authorization<token>🗝️ API key in format: 'Bearer sk-xxxxxx'
In: header
Request Body
application/jsonRequiredsessionDurationSessionduration3600directPaymentDirectpaymentfalsefailoverFailoverfalseQuery Parameters
model_idRequiredModel IdThe blockchain ID (hex) of the model to create a session for
Response Body
Successful Response
TypeScript Definitions
Use the response body type in TypeScript.
responseRequiredunknownValidation Error
TypeScript Definitions
Use the response body type in TypeScript.
detailDetailcurl -X POST "https://example.com/api/v1/session/modelsession?model_id=string" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"sessionDuration": 3600,
"directPayment": false,
"failover": false
}'const body = JSON.stringify({
"sessionDuration": 3600,
"directPayment": false,
"failover": false
})
fetch("https://example.com/api/v1/session/modelsession?model_id=string", {
headers: {
"Authorization": "Bearer <token>"
},
body
})package main
import (
"fmt"
"net/http"
"io/ioutil"
"strings"
)
func main() {
url := "https://example.com/api/v1/session/modelsession?model_id=string"
body := strings.NewReader(`{
"sessionDuration": 3600,
"directPayment": false,
"failover": false
}`)
req, _ := http.NewRequest("POST", url, body)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}import requests
url = "https://example.com/api/v1/session/modelsession?model_id=string"
body = {
"sessionDuration": 3600,
"directPayment": false,
"failover": false
}
response = requests.request("POST", url, json = body, headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
})
print(response.text)null{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string"
}
]
}How is this guide?
Create Bid Session POST
Create a session with a provider using a bid ID and associate it with the API key. This endpoint creates a session and automatically associates it with the API key used for authentication. Each API key can have at most one active session at a time.
Ping Session POST
Ping the session by attempting a simple chat completion. If the chat completion fails, the session is considered dead and will be closed.