Embeddings
Embeddings and rerank
POST /v1/embeddings and POST /v1/rerank, with the embedding model list.
POST https://api.pre.dev/v1/embeddings takes the OpenAI-compatible embeddings request and returns the embeddings response. GET /v1/embeddings/models lists embedding models with credit prices; it is free and not rate-limited.
curl --fail-with-body https://api.pre.dev/v1/embeddings \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/text-embedding-3-small", "input": ["pre.dev builds software from a spec", "credits pay for model calls"]}'import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY! });
const result = await client.embeddings.create({
model: 'openai/text-embedding-3-small',
input: ['pre.dev builds software from a spec', 'credits pay for model calls'],
});
console.log(result.data[0].embedding.length, result.usage);import os
from openai import OpenAI
client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
result = client.embeddings.create(
model="openai/text-embedding-3-small",
input=["pre.dev builds software from a spec", "credits pay for model calls"],
)
print(len(result.data[0].embedding), result.usage)The response is the standard embeddings response: data[].embedding, model, and usage. The call is charged from its metered usage, reported in x-predev-credits-charged.
Rerank
POST /v1/rerank ranks documents against a query. Send a model, a query, and documents; the response returns the documents ordered by relevance with a score for each.
curl --fail-with-body https://api.pre.dev/v1/rerank \
-H "Authorization: Bearer $PREDEV_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cohere/rerank-v3.5",
"query": "how are gateway calls billed",
"documents": [
"Credits are computed from the metered usage of each call.",
"Streams settle when they end.",
"Catalog reads are free."
]
}'Rerank models are not returned by GET /v1/models or GET /v1/models/public. These ids work today: cohere/rerank-v3.5, cohere/rerank-4-fast, cohere/rerank-4-pro, voyageai/rerank-2.5, voyageai/rerank-2.5-lite, and qwen/qwen3-reranker-8b. Rerank calls are billed like any other inference call. See the rerank reference.
curl --fail-with-body https://api.pre.dev/v1/embeddings \ -H "Authorization: Bearer $PREDEV_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "openai/text-embedding-3-small", "input": ["pre.dev builds software from a spec", "credits pay for model calls"]}'import osfrom openai import OpenAIclient = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])result = client.embeddings.create( model="openai/text-embedding-3-small", input=["pre.dev builds software from a spec", "credits pay for model calls"],)print(len(result.data[0].embedding))import OpenAI from 'openai';const client = new OpenAI({ baseURL: 'https://api.pre.dev/v1', apiKey: process.env.PREDEV_API_KEY });const result = await client.embeddings.create({ model: 'openai/text-embedding-3-small', input: ['pre.dev builds software from a spec', 'credits pay for model calls'],});console.log(result.data[0].embedding.length);package mainimport ( "fmt" "net/http" "io/ioutil" "strings")func main() { url := "https://api.pre.dev/v1/embeddings" body := strings.NewReader(`{ "model": "openai/text-embedding-3-small", "input": [ "pre.dev builds software from a spec", "credits pay for model calls" ] }`) req, _ := http.NewRequest("POST", url, body) 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 java.net.URI;import java.net.http.HttpClient;import java.net.http.HttpRequest;import java.net.http.HttpResponse;import java.net.http.HttpResponse.BodyHandlers;import java.time.Duration;import java.net.http.HttpRequest.BodyPublishers;var body = BodyPublishers.ofString("""{ "model": "openai/text-embedding-3-small", "input": [ "pre.dev builds software from a spec", "credits pay for model calls" ]}""");HttpClient client = HttpClient.newBuilder() .connectTimeout(Duration.ofSeconds(10)) .build();HttpRequest.Builder requestBuilder = HttpRequest.newBuilder() .uri(URI.create("https://api.pre.dev/v1/embeddings")) .header("Content-Type", "application/json") .POST(body) .build();try { HttpResponse<String> response = client.send(requestBuilder.build(), BodyHandlers.ofString()); System.out.println("Status code: " + response.statusCode()); System.out.println("Response body: " + response.body());} catch (Exception e) { e.printStackTrace();}using System;using System.Net.Http;using System.Text;var body = new StringContent("""{ "model": "openai/text-embedding-3-small", "input": [ "pre.dev builds software from a spec", "credits pay for model calls" ]}""", Encoding.UTF8, "application/json");var client = new HttpClient();var response = await client.PostAsync("https://api.pre.dev/v1/embeddings", body);var responseBody = await response.Content.ReadAsStringAsync();use reqwest::{Result, Client};async fn main() -> Result<()> { let client = Client::new(); let url = "https://api.pre.dev/v1/embeddings"; let body = r#"{ "model": "openai/text-embedding-3-small", "input": [ "pre.dev builds software from a spec", "credits pay for model calls" ] }"#; let res = client .post(url) .header("Content-Type", "application/json") .body(body) .send() .await? .text() .await?; println!("{}", res); Ok(())}{ "object": "list", "data": [ { "object": "embedding", "index": 0, "embedding": [ 0.0123, -0.0456, 0.0789 ] }, { "object": "embedding", "index": 1, "embedding": [ -0.0211, 0.0302, 0.0118 ] } ], "model": "openai/text-embedding-3-small", "usage": { "prompt_tokens": 13, "total_tokens": 13 }}The workspace API key (pdk_…) from Integrations → Built-in in the pre.dev dashboard.
In: header
Header Parameters
Attribute this call to one of the workspace's projects. An id the workspace does not own is ignored.
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
One embedding per input, in input order.
TypeScript Definitions
Use the response body type in TypeScript.
application/json
The body is not valid JSON (checked before authentication), or the model rejected the request, for example an unknown model id. Errors from the model keep their status and use the ModelError shape.
TypeScript Definitions
Use the response body type in TypeScript.
The request body is not valid JSON. Checked before authentication.
application/json
Missing or invalid API key.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.
application/json
The workspace cannot pay for this request. Nothing was sent to the model and nothing was charged.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.
application/json
The request refers to a file, response or video job that is not this workspace's (not_found from pre.dev; nothing ran and nothing was charged), or the model could not serve the request (its own status and message, in the ModelError shape).
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.
application/json
Too many requests. Wait Retry-After seconds when it is present. A rate_limit_exceeded refusal is per workspace per minute (600, or 30 on the free trial). An error from the model keeps the ModelError shape.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.
application/json
Unexpected error.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.
application/json
The model did not answer. Retry with backoff, or send models fallbacks.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.
application/json
The credit balance could not be read, so nothing ran. Retry after Retry-After seconds.
TypeScript Definitions
Use the response body type in TypeScript.
An error raised by pre.dev, in the OpenAI error shape with an extra predev object (absent on catalog_unavailable from the catalog listings). Branch on error.code.