Skip to main content
POST
/
v1
/
generation
/
api-key
Create API Key
curl --request POST \
  --url https://api.weryai.com/v1/generation/api-key \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "desc": "My production key",
  "trace_id": "trace_xxx"
}
'
import requests

url = "https://api.weryai.com/v1/generation/api-key"

payload = {
"desc": "My production key",
"trace_id": "trace_xxx"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({desc: 'My production key', trace_id: 'trace_xxx'})
};

fetch('https://api.weryai.com/v1/generation/api-key', 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.weryai.com/v1/generation/api-key",
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([
'desc' => 'My production key',
'trace_id' => 'trace_xxx'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.weryai.com/v1/generation/api-key"

payload := strings.NewReader("{\n \"desc\": \"My production key\",\n \"trace_id\": \"trace_xxx\"\n}")

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

req.Header.Add("Authorization", "Bearer <token>")
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.weryai.com/v1/generation/api-key")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"desc\": \"My production key\",\n \"trace_id\": \"trace_xxx\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.weryai.com/v1/generation/api-key")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"desc\": \"My production key\",\n \"trace_id\": \"trace_xxx\"\n}"

response = http.request(request)
puts response.read_body
{
  "status": 0,
  "desc": "success",
  "message": "success",
  "data": {
    "desc": "My production key",
    "api_key": "sk-xxxxxxxxxxxxxxxx",
    "trace_id": "trace_xxx",
    "create_time": 1710000000000
  }
}
{
"status": 1001,
"desc": "Parameter error",
"message": "Prompt cannot be empty"
}
{
"status": 1002,
"desc": "Authentication failed",
"message": "Invalid API Key"
}

Authorizations

Authorization
string
header
required

Authenticate using Bearer token. Get your API Key from the WeryAI Console.

Example: Authorization: Bearer sk-xxxxxxxxxxxxxxxx

Body

application/json
desc
string
required

API Key description. Minimum 3 characters and maximum 100 characters.

Required string length: 3 - 100
Example:

"My production key"

trace_id
string
required

Trace identifier for request tracing. Must be 3 to 100 characters and contain only letters, numbers, underscore (_), or hyphen (-).

Required string length: 3 - 100
Example:

"trace_xxx"

Response

API Key created successfully

status
integer

Business status code

Example:

0

desc
string

Status description

Example:

"success"

message
string

Multi-language message

Example:

"success"

data
object