Create a text completion
curl --request POST \
--url https://api.pre.dev/v1/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "deepseek/deepseek-v4.1-flash",
"prompt": "The sky is blue because"
}
'import requests
url = "https://api.pre.dev/v1/completions"
payload = {
"model": "deepseek/deepseek-v4.1-flash",
"prompt": "The sky is blue because"
}
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({model: 'deepseek/deepseek-v4.1-flash', prompt: 'The sky is blue because'})
};
fetch('https://api.pre.dev/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://api.pre.dev/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_POSTFIELDS => json_encode([
'model' => 'deepseek/deepseek-v4.1-flash',
'prompt' => 'The sky is blue because'
]),
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.pre.dev/v1/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"prompt\": \"The sky is blue because\"\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.pre.dev/v1/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"prompt\": \"The sky is blue because\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/completions")
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 \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"prompt\": \"The sky is blue because\"\n}"
response = http.request(request)
puts response.read_body{
"id": "pdg-043293a6-d1a8-4695-81fe-603ad4661ebb",
"object": "text_completion",
"created": 1790500000,
"model": "deepseek/deepseek-v4.1-flash",
"choices": [
{
"index": 0,
"text": " sunlight scatters off air molecules.",
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 6,
"completion_tokens": 7,
"total_tokens": 13
}
}Chat
Text completions
Legacy text completions in the OpenAI format: a prompt string instead of messages.
POST
/
v1
/
completions
Create a text completion
curl --request POST \
--url https://api.pre.dev/v1/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "deepseek/deepseek-v4.1-flash",
"prompt": "The sky is blue because"
}
'import requests
url = "https://api.pre.dev/v1/completions"
payload = {
"model": "deepseek/deepseek-v4.1-flash",
"prompt": "The sky is blue because"
}
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({model: 'deepseek/deepseek-v4.1-flash', prompt: 'The sky is blue because'})
};
fetch('https://api.pre.dev/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://api.pre.dev/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_POSTFIELDS => json_encode([
'model' => 'deepseek/deepseek-v4.1-flash',
'prompt' => 'The sky is blue because'
]),
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.pre.dev/v1/completions"
payload := strings.NewReader("{\n \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"prompt\": \"The sky is blue because\"\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.pre.dev/v1/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"prompt\": \"The sky is blue because\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pre.dev/v1/completions")
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 \"model\": \"deepseek/deepseek-v4.1-flash\",\n \"prompt\": \"The sky is blue because\"\n}"
response = http.request(request)
puts response.read_body{
"id": "pdg-043293a6-d1a8-4695-81fe-603ad4661ebb",
"object": "text_completion",
"created": 1790500000,
"model": "deepseek/deepseek-v4.1-flash",
"choices": [
{
"index": 0,
"text": " sunlight scatters off air molecules.",
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 6,
"completion_tokens": 7,
"total_tokens": 13
}
}Authorizations
apiKeyAuthxApiKey
The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.
Headers
Attribute this call to one of the workspace's projects. An id the workspace does not own is ignored.
Body
application/json
Response
The completion, or server-sent chunks when stream is true.
Generation id (pdg-…).
Show child attributes
Show child attributes
Allowed value:
"text_completion"Token counts for the call. Charges are reported in credits by the x-predev-credits-charged header and GET /v1/generation.
Show child attributes
Show child attributes
Was this page helpful?

