π¬Chat Completions
Chat with any AI model instantly, perfect for e-sex (If you're into that of course).
Models can be found here.
import requests
# Set your API key here to authenticate
headers = {"Authorization": "Bearer shard-xxx"}
# Set the body for the request
data = {
"messages": [
{"role": "user", "content": 'Hi!'}, # Prompt goes here
],
"model": "gpt-3.5-turbo" # Model goes here
}
# URL for posting requests.
url = "https://api.shard-ai.xyz/v1/chat/completions"
# Send the request to request a chat response
response = requests.post(url, headers=headers)
# Print the full response!
print(response.json())
# Print the AI's response!
print(response.json()['choices'][0]['message']['content'])
package main
import (
"fmt"
"github.com/valyala/fasthttp"
"log"
)
func main() {
// Set your API key here to authenticate
headers := fasthttp.Header{}
headers.Set("Authorization", "Bearer shard-xxx")
// Set the body for the request
data := `{
"messages": [
{"role": "user", "content": "Hi!"} // Prompt goes here
],
"model": "gpt-3.5-turbo" // Model goes here
}`
// URL for posting requests.
url := "https://api.shard-ai.xyz/v1/chat/completions"
// Send the request to request a chat response
statusCode, body, err := fasthttp.Post(nil, url, headers, []byte(data))
if err != nil {
log.Fatalf("Error: %s", err)
}
// Print the full response!
fmt.Printf("Response status: %d\n", statusCode)
fmt.Printf("Response body: %s\n", body)
// TODO: Print the AI's response!
}
// import axios
const axios = require('axios');
// Set your API key here to authenticate
const headers = {"Authorization": "Bearer shard-xxx"};
// Set the body for the request
const data = {
"messages": [
{"role": "user", "content": 'Hi!'}, // Prompt goes here
],
"model": "gpt-3.5-turbo", // Model goes here
};
// URL for posting requests.
const url = "https://api.shard-ai.xyz/v1/chat/completions"; // Send the request to request a chat response
axios.post(url, data, {headers: headers})
.then(response => {
// Print the full response!
console.log(response.data);
// Print the AI's response!
console.log(response.data['choices'][0]['message']['content']);
})
.catch(error => {
console.error(error);
});
Last updated