Introduction
Create session from text-to-image.
Create Session
Request
POST /tti-sessions
Parameters
prompt REQUIRED
type : string
in : body
example : "Basic Car with black color"
description : Add objects, colors, places, characters
style_id OPTIONAL
type : string
in : body
description : ID of the style
Code Snippets
Python
import requests
import json
url = "https://api.csm.ai/tti-sessions"
payload = json.dumps({
"prompt": "Basic Car with black color",
})
headers = {
'x-api-key': '<X-API_KEY>',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Node.js
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://api.csm.ai/tti-sessions',
'headers': {
'x-api-key': '<X-API_KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"prompt": "Basic Car with black color",
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
Curl
curl -k --location 'https://api.csm.ai/tti-sessions' \
--header 'x-api-key: <X-API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"prompt": "Walk Dog",
}'
Response
{
"error": "",
"message": "Created",
"statusCode": 201,
"data": {
"session_code": "SESSION_1702539509_6543578",
"style_id": "",
"prompt": "Walk dog",
"guidance": 6,
"user_id": "62fdb597f3efdd2e0a094fdc",
"image_url": "",
"type": "manual",
"status": "processing",
"is_deleted": false,
"_id": "657ab0f50a9ba3ecb6f53654",
"created_at": "2023-12-14T07:38:29.952Z",
"updated_at": "2023-12-14T07:38:29.952Z"
}
}