Create a completion (legacy)
curl --request POST \
--url https://kymaapi.com/v1/completions \
--header 'Authorization: Bearer <token>'import requests
url = "https://kymaapi.com/v1/completions"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://kymaapi.com/v1/completions', 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://kymaapi.com/v1/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://kymaapi.com/v1/completions"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://kymaapi.com/v1/completions")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://kymaapi.com/v1/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyEndpoints
Create a completion (legacy)
OpenAI’s deprecated text-completion shape, served for compatibility.
POST
/
v1
/
completions
Create a completion (legacy)
curl --request POST \
--url https://kymaapi.com/v1/completions \
--header 'Authorization: Bearer <token>'import requests
url = "https://kymaapi.com/v1/completions"
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
fetch('https://kymaapi.com/v1/completions', 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://kymaapi.com/v1/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://kymaapi.com/v1/completions"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://kymaapi.com/v1/completions")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://kymaapi.com/v1/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyOpenAI deprecated this endpoint. It exists so older SDK pins and scripts keep working — use
/v1/chat/completions for anything new.What it is
An adapter over the chat endpoint, not a separate path.prompt becomes a single user message, and choices[].message.content comes back as choices[].text. Models, pricing, streaming and failover are identical, because the request goes through exactly the same pipeline. One difference: usage (with usage.cost) comes back only on non-streaming calls. The legacy stream shape has no usage frame, so a streaming caller does not see it.
from openai import OpenAI
client = OpenAI(api_key="kyma-...", base_url="https://api.kymaapi.com/v1")
r = client.completions.create(
model="qwen3.7-flash",
prompt="Write a haiku about routing",
max_tokens=64,
)
print(r.choices[0].text)
Three things return 400 instead of guessing
| You sent | Why it is refused |
|---|---|
prompt: ["a", "b"] | A one-element array is accepted. With two or more, the original API means two independent completions. Concatenating them would return one answer where you expect two — send one request per prompt. |
suffix | Fill-in-the-middle. No chat model does it, so honouring it would return a plausible completion that is wrong for the purpose. |
echo and stream | echo prepends your prompt, which has nowhere to go in a token stream without inventing a frame you did not ask for. |
best_of and logprobs are accepted and ignored — their absence is visible in the response, so there is nothing to guess about.
Streaming
Supported, in the legacy chunk shape:data: {"id":"...","object":"text_completion","choices":[{"text":"One","index":0,"logprobs":null,"finish_reason":null}]}
finish_reason, so it is dropped rather than emitted as an empty chunk.