curl --request POST \
--url https://api.galadriel.com/v1/chat/completions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"content": "You are a helpful assistant.",
"role": "system"
},
{
"content": "Hello!",
"role": "user"
}
],
"model": "llama3.1"
}
'import requests
url = "https://api.galadriel.com/v1/chat/completions"
payload = {
"messages": [
{
"content": "You are a helpful assistant.",
"role": "system"
},
{
"content": "Hello!",
"role": "user"
}
],
"model": "llama3.1"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [
{content: 'You are a helpful assistant.', role: 'system'},
{content: 'Hello!', role: 'user'}
],
model: 'llama3.1'
})
};
fetch('https://api.galadriel.com/v1/chat/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.galadriel.com/v1/chat/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([
'messages' => [
[
'content' => 'You are a helpful assistant.',
'role' => 'system'
],
[
'content' => 'Hello!',
'role' => 'user'
]
],
'model' => 'llama3.1'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.galadriel.com/v1/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"You are a helpful assistant.\",\n \"role\": \"system\"\n },\n {\n \"content\": \"Hello!\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"llama3.1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.galadriel.com/v1/chat/completions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"content\": \"You are a helpful assistant.\",\n \"role\": \"system\"\n },\n {\n \"content\": \"Hello!\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"llama3.1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.galadriel.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"content\": \"You are a helpful assistant.\",\n \"role\": \"system\"\n },\n {\n \"content\": \"Hello!\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"llama3.1\"\n}"
response = http.request(request)
puts response.read_body{
"id": "id",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Hello. It's nice to meet you. Is there something I can help you with or would you like to chat?",
"refusal": null,
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}
],
"created": 1728558433,
"model": "neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": null
}
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":"","role":"assistant"},"finish_reason":null,"index":0,"logprobs":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":"Hello"},"finish_reason":null,"index":0,"logprobs":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
...
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":""},"finish_reason":"stop","index":0,"logprobs":null,"stop_reason":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
data: [DONE]
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
{
"response": "NOK",
"error": {
"status_code": 429,
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded"
}
}
{
"response": "NOK",
"error": {
"status_code": 503,
"code": "no_available_inference_nodes",
"message": "No available inference nodes to process the request."
}
}
event: error
data: {"error": {"message": "No available inference nodes to process the request."}}
Chat Completion API
Tap into Galadriel’s LLM inference network. Follows the same schema as OpenAI’s chat completion API.
curl --request POST \
--url https://api.galadriel.com/v1/chat/completions \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"messages": [
{
"content": "You are a helpful assistant.",
"role": "system"
},
{
"content": "Hello!",
"role": "user"
}
],
"model": "llama3.1"
}
'import requests
url = "https://api.galadriel.com/v1/chat/completions"
payload = {
"messages": [
{
"content": "You are a helpful assistant.",
"role": "system"
},
{
"content": "Hello!",
"role": "user"
}
],
"model": "llama3.1"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messages: [
{content: 'You are a helpful assistant.', role: 'system'},
{content: 'Hello!', role: 'user'}
],
model: 'llama3.1'
})
};
fetch('https://api.galadriel.com/v1/chat/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.galadriel.com/v1/chat/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([
'messages' => [
[
'content' => 'You are a helpful assistant.',
'role' => 'system'
],
[
'content' => 'Hello!',
'role' => 'user'
]
],
'model' => 'llama3.1'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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.galadriel.com/v1/chat/completions"
payload := strings.NewReader("{\n \"messages\": [\n {\n \"content\": \"You are a helpful assistant.\",\n \"role\": \"system\"\n },\n {\n \"content\": \"Hello!\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"llama3.1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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.galadriel.com/v1/chat/completions")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"messages\": [\n {\n \"content\": \"You are a helpful assistant.\",\n \"role\": \"system\"\n },\n {\n \"content\": \"Hello!\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"llama3.1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.galadriel.com/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messages\": [\n {\n \"content\": \"You are a helpful assistant.\",\n \"role\": \"system\"\n },\n {\n \"content\": \"Hello!\",\n \"role\": \"user\"\n }\n ],\n \"model\": \"llama3.1\"\n}"
response = http.request(request)
puts response.read_body{
"id": "id",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Hello. It's nice to meet you. Is there something I can help you with or would you like to chat?",
"refusal": null,
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}
],
"created": 1728558433,
"model": "neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": null
}
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":"","role":"assistant"},"finish_reason":null,"index":0,"logprobs":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":"Hello"},"finish_reason":null,"index":0,"logprobs":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
...
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":""},"finish_reason":"stop","index":0,"logprobs":null,"stop_reason":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
data: [DONE]
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
{
"response": "NOK",
"error": {
"status_code": 429,
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded"
}
}
{
"response": "NOK",
"error": {
"status_code": 503,
"code": "no_available_inference_nodes",
"message": "No available inference nodes to process the request."
}
}
event: error
data: {"error": {"message": "No available inference nodes to process the request."}}
{
"id": "id",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Hello. It's nice to meet you. Is there something I can help you with or would you like to chat?",
"refusal": null,
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}
],
"created": 1728558433,
"model": "neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": null
}
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":"","role":"assistant"},"finish_reason":null,"index":0,"logprobs":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":"Hello"},"finish_reason":null,"index":0,"logprobs":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
...
data: {"id":"chat-50ad61812fd147158e3776bf89c18698","choices":[{"delta":{"content":""},"finish_reason":"stop","index":0,"logprobs":null,"stop_reason":null}],"created":1729078303,"model":"neuralmagic/Meta-Llama-3.1-8B-Instruct-FP8","object":"chat.completion.chunk","usage":null}
data: [DONE]
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}
{
"response": "NOK",
"error": {
"status_code": 429,
"code": "rate_limit_exceeded",
"message": "Rate limit exceeded"
}
}
{
"response": "NOK",
"error": {
"status_code": 503,
"code": "no_available_inference_nodes",
"message": "No available inference nodes to process the request."
}
}
event: error
data: {"error": {"message": "No available inference nodes to process the request."}}
Authorizations
Bearer authentication header.
example value: Bearer Galadriel-API-key
Get API key from Galadriel dashboard.
Body
ID of the model to use. Get ID for available models.
The maximum number of tokens to generate in the chat completion. Models specific.
This feature is in Beta. If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result. Determinism is not guaranteed, and you should refer to the system_fingerprint response parameter to monitor changes in the backend.
Controls which (if any) tool is called by the model. none means the model will not call any tool and instead generates a message. auto means the model can pick between generating a message or calling one or more tools. required means the model must call one or more tools. Specifying a particular tool via {"type": "function", "function": {"name": "my_function"}} forces the model to call that tool.
Response
Returns a chat completion object, or a streamed sequence of chat completion chunk objects if the request is streamed.

