Chat
curl --request POST \
--url http://localhost:8000/api/engine/chat/{provider} \
--header 'Content-Type: application/json' \
--data '
{
"api_key": "<string>",
"model": "<string>",
"chat_input": "<string>",
"parameters": "<any>",
"is_stream": "<any>"
}
'import requests
url = "http://localhost:8000/api/engine/chat/{provider}"
payload = {
"api_key": "<string>",
"model": "<string>",
"chat_input": "<string>",
"parameters": "<any>",
"is_stream": "<any>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
api_key: '<string>',
model: '<string>',
chat_input: '<string>',
parameters: '<any>',
is_stream: '<any>'
})
};
fetch('http://localhost:8000/api/engine/chat/{provider}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8000",
CURLOPT_URL => "http://localhost:8000/api/engine/chat/{provider}",
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([
'api_key' => '<string>',
'model' => '<string>',
'chat_input' => '<string>',
'parameters' => '<any>',
'is_stream' => '<any>'
]),
CURLOPT_HTTPHEADER => [
"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 := "http://localhost:8000/api/engine/chat/{provider}"
payload := strings.NewReader("{\n \"api_key\": \"<string>\",\n \"model\": \"<string>\",\n \"chat_input\": \"<string>\",\n \"parameters\": \"<any>\",\n \"is_stream\": \"<any>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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("http://localhost:8000/api/engine/chat/{provider}")
.header("Content-Type", "application/json")
.body("{\n \"api_key\": \"<string>\",\n \"model\": \"<string>\",\n \"chat_input\": \"<string>\",\n \"parameters\": \"<any>\",\n \"is_stream\": \"<any>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8000/api/engine/chat/{provider}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"api_key\": \"<string>\",\n \"model\": \"<string>\",\n \"chat_input\": \"<string>\",\n \"parameters\": \"<any>\",\n \"is_stream\": \"<any>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "72f34d3b-f254-4950-9d6f-9f66e082fd2f",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Hello! I am a virtual assistant here to help with any questions or tasks you may have. How can I assist you today?",
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}
],
"created": 1718622757,
"model": "gpt-3.5-turbo",
"object": "chat.completion",
"system_fingerprint": null,
"usage": null,
"session_id": null,
"chat_input": "Hello! Who are you?",
"chat_output": "Hello! I am a virtual assistant here to help with any questions or tasks you may have. How can I assist you today?",
"context": [
{
"role": "user",
"content": "Hello! Who are you?"
}
],
"provider": "openai",
"timestamp": 1718622757.612226,
"parameters": {
"temperature": 1,
"max_tokens": 2048,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
},
"metrics": {
"input_tokens": 6,
"output_tokens": 26,
"total_tokens": 32,
"cost_usd": 0.000061,
"latency_s": 1.0556859970092773,
"time_to_first_token_s": 0.8302950859069824,
"inter_token_latency_s": 0.008317514702125831,
"tokens_per_second": 26.523038175483098
}
}
LLM
Chat
Lists all providers supported by LLMstudio
POST
/
api
/
engine
/
chat
/
{provider}
Chat
curl --request POST \
--url http://localhost:8000/api/engine/chat/{provider} \
--header 'Content-Type: application/json' \
--data '
{
"api_key": "<string>",
"model": "<string>",
"chat_input": "<string>",
"parameters": "<any>",
"is_stream": "<any>"
}
'import requests
url = "http://localhost:8000/api/engine/chat/{provider}"
payload = {
"api_key": "<string>",
"model": "<string>",
"chat_input": "<string>",
"parameters": "<any>",
"is_stream": "<any>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
api_key: '<string>',
model: '<string>',
chat_input: '<string>',
parameters: '<any>',
is_stream: '<any>'
})
};
fetch('http://localhost:8000/api/engine/chat/{provider}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_PORT => "8000",
CURLOPT_URL => "http://localhost:8000/api/engine/chat/{provider}",
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([
'api_key' => '<string>',
'model' => '<string>',
'chat_input' => '<string>',
'parameters' => '<any>',
'is_stream' => '<any>'
]),
CURLOPT_HTTPHEADER => [
"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 := "http://localhost:8000/api/engine/chat/{provider}"
payload := strings.NewReader("{\n \"api_key\": \"<string>\",\n \"model\": \"<string>\",\n \"chat_input\": \"<string>\",\n \"parameters\": \"<any>\",\n \"is_stream\": \"<any>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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("http://localhost:8000/api/engine/chat/{provider}")
.header("Content-Type", "application/json")
.body("{\n \"api_key\": \"<string>\",\n \"model\": \"<string>\",\n \"chat_input\": \"<string>\",\n \"parameters\": \"<any>\",\n \"is_stream\": \"<any>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("http://localhost:8000/api/engine/chat/{provider}")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"api_key\": \"<string>\",\n \"model\": \"<string>\",\n \"chat_input\": \"<string>\",\n \"parameters\": \"<any>\",\n \"is_stream\": \"<any>\"\n}"
response = http.request(request)
puts response.read_body{
"id": "72f34d3b-f254-4950-9d6f-9f66e082fd2f",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Hello! I am a virtual assistant here to help with any questions or tasks you may have. How can I assist you today?",
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}
],
"created": 1718622757,
"model": "gpt-3.5-turbo",
"object": "chat.completion",
"system_fingerprint": null,
"usage": null,
"session_id": null,
"chat_input": "Hello! Who are you?",
"chat_output": "Hello! I am a virtual assistant here to help with any questions or tasks you may have. How can I assist you today?",
"context": [
{
"role": "user",
"content": "Hello! Who are you?"
}
],
"provider": "openai",
"timestamp": 1718622757.612226,
"parameters": {
"temperature": 1,
"max_tokens": 2048,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
},
"metrics": {
"input_tokens": 6,
"output_tokens": 26,
"total_tokens": 32,
"cost_usd": 0.000061,
"latency_s": 1.0556859970092773,
"time_to_first_token_s": 0.8302950859069824,
"inter_token_latency_s": 0.008317514702125831,
"tokens_per_second": 26.523038175483098
}
}
API key to access the provider
API key to access the provider
API key to access the provider
API key to access the provider
API key to access the provider
{
"id": "72f34d3b-f254-4950-9d6f-9f66e082fd2f",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"logprobs": null,
"message": {
"content": "Hello! I am a virtual assistant here to help with any questions or tasks you may have. How can I assist you today?",
"role": "assistant",
"function_call": null,
"tool_calls": null
}
}
],
"created": 1718622757,
"model": "gpt-3.5-turbo",
"object": "chat.completion",
"system_fingerprint": null,
"usage": null,
"session_id": null,
"chat_input": "Hello! Who are you?",
"chat_output": "Hello! I am a virtual assistant here to help with any questions or tasks you may have. How can I assist you today?",
"context": [
{
"role": "user",
"content": "Hello! Who are you?"
}
],
"provider": "openai",
"timestamp": 1718622757.612226,
"parameters": {
"temperature": 1,
"max_tokens": 2048,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0
},
"metrics": {
"input_tokens": 6,
"output_tokens": 26,
"total_tokens": 32,
"cost_usd": 0.000061,
"latency_s": 1.0556859970092773,
"time_to_first_token_s": 0.8302950859069824,
"inter_token_latency_s": 0.008317514702125831,
"tokens_per_second": 26.523038175483098
}
}
⌘I