cURL
curl --request POST \
--url https://embeddings.endpoint.relace.run/v1/code/embed \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "relace-embed-v1",
"input": [
"input 1",
"input 2"
]
}
'import requests
url = "https://embeddings.endpoint.relace.run/v1/code/embed"
payload = {
"model": "relace-embed-v1",
"input": ["input 1", "input 2"]
}
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: 'relace-embed-v1', input: ['input 1', 'input 2']})
};
fetch('https://embeddings.endpoint.relace.run/v1/code/embed', 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://embeddings.endpoint.relace.run/v1/code/embed",
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' => 'relace-embed-v1',
'input' => [
'input 1',
'input 2'
]
]),
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://embeddings.endpoint.relace.run/v1/code/embed"
payload := strings.NewReader("{\n \"model\": \"relace-embed-v1\",\n \"input\": [\n \"input 1\",\n \"input 2\"\n ]\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://embeddings.endpoint.relace.run/v1/code/embed")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"relace-embed-v1\",\n \"input\": [\n \"input 1\",\n \"input 2\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://embeddings.endpoint.relace.run/v1/code/embed")
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\": \"relace-embed-v1\",\n \"input\": [\n \"input 1\",\n \"input 2\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
[
{
"index": 0,
"embedding": [
0.123,
0.456,
0.789
]
},
{
"index": 1,
"embedding": [
0.234,
0.567,
0.89
]
}
]
],
"usage": {
"total_tokens": 8
}
}{
"error": "Invalid JSON in request body"
}{
"error": "Authorized header required"
}{
"error": "Bad Request: Route not found"
}{
"error": "Rate limit exceeded"
}{
"error": "Error fetching from origin server"
}Embeddings Model
Embed Code
Embed code snippets into a vector database for semantic search.
POST
/
v1
/
code
/
embed
cURL
curl --request POST \
--url https://embeddings.endpoint.relace.run/v1/code/embed \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "relace-embed-v1",
"input": [
"input 1",
"input 2"
]
}
'import requests
url = "https://embeddings.endpoint.relace.run/v1/code/embed"
payload = {
"model": "relace-embed-v1",
"input": ["input 1", "input 2"]
}
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: 'relace-embed-v1', input: ['input 1', 'input 2']})
};
fetch('https://embeddings.endpoint.relace.run/v1/code/embed', 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://embeddings.endpoint.relace.run/v1/code/embed",
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' => 'relace-embed-v1',
'input' => [
'input 1',
'input 2'
]
]),
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://embeddings.endpoint.relace.run/v1/code/embed"
payload := strings.NewReader("{\n \"model\": \"relace-embed-v1\",\n \"input\": [\n \"input 1\",\n \"input 2\"\n ]\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://embeddings.endpoint.relace.run/v1/code/embed")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"relace-embed-v1\",\n \"input\": [\n \"input 1\",\n \"input 2\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://embeddings.endpoint.relace.run/v1/code/embed")
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\": \"relace-embed-v1\",\n \"input\": [\n \"input 1\",\n \"input 2\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"results": [
[
{
"index": 0,
"embedding": [
0.123,
0.456,
0.789
]
},
{
"index": 1,
"embedding": [
0.234,
0.567,
0.89
]
}
]
],
"usage": {
"total_tokens": 8
}
}{
"error": "Invalid JSON in request body"
}{
"error": "Authorized header required"
}{
"error": "Bad Request: Route not found"
}{
"error": "Rate limit exceeded"
}{
"error": "Error fetching from origin server"
}Authorizations
Relace API key Authorization header using the Bearer scheme.
Body
application/json
Codebase context for embedding
The model to use for embedding
Array of strings to embed
Data type of the output embedding vectors. The binary quantization results in more compact embeddings with only a small loss in retrieval performance. See HuggingFace blog post for details.
Available options:
float, binary ⌘I