Quickstart
Oraicle is an OpenAI-compatible API for open models, plus live-data oracles the model can call while it answers. Point an OpenAI client at the base URL below and use your Oraicle key.
Base URL
Section titled “Base URL”https://api.oraicle.me/v1Quick Start
Section titled “Quick Start”Here’s how to make your first API call in various programming languages:
from openai import OpenAI
# Set your API key and base URLclient = OpenAI( base_url = "https://api.oraicle.me/v1", # For production, you should not place your key # in the code but in the environment variables api_key = "<your_api_key>",)
# Make a simple chat completion requestresponse = client.chat.completions.create( model="deepseek-ai/DeepSeek-R1-0528", messages=[ {"role": "system", "content": "You are a smarter assistant."}, { "role": "user", "content": "In two sentences, what is an API key and why should I keep it secret?" } ])
print(response.choices[0].message.content)import { OpenAI } from "openai";
// Set up the client with your API key and base URLconst openai = new OpenAI({ apiKey: "<your_api_key>", baseURL: "https://api.oraicle.me/v1"});
async function callAPI() { const completion = await openai.chat.completions.create({ model: "deepseek-ai/DeepSeek-R1-0528", messages: [ { role: "system", content: "You are a smarter assistant." }, { role: "user", content: "In two sentences, what is an API key and why should I keep it secret?" } ], });
console.log(completion.choices[0].message.content);}
callAPI();curl https://api.oraicle.me/v1/chat/completions \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <your_api_key>" \ -d '{ "model": "deepseek-ai/DeepSeek-R1-0528", "messages": [ { "role": "system", "content": "You are a smarter assistant." }, { "role": "user", "content": "In two sentences, what is an API key and why should I keep it secret?" } ] }'import com.theokanning.openai.completion.chat.ChatCompletionRequest;import com.theokanning.openai.completion.chat.ChatMessage;import com.theokanning.openai.completion.chat.ChatMessageRole;import com.theokanning.openai.service.OpenAiService;import retrofit2.Retrofit;
import java.time.Duration;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;
public class OraicleExample { public static void main(String[] args) { String token = "<your_api_key>"; String baseUrl = "https://api.oraicle.me/v1";
// Create a service with custom base URL OpenAiService service = new OpenAiService(token, Duration.ofSeconds(30), baseUrl);
List messages = new ArrayList<>(); messages.add(new ChatMessage(ChatMessageRole.SYSTEM.value(), "You are a smarter assistant.")); messages.add(new ChatMessage(ChatMessageRole.USER.value(), "In two sentences, what is an API key and why should I keep it secret?"));
ChatCompletionRequest completionRequest = ChatCompletionRequest.builder() .model("deepseek-ai/DeepSeek-R1-0528") .messages(messages) .build();
service.createChatCompletion(completionRequest) .getChoices() .forEach(choice -> System.out.println(choice.getMessage().getContent())); }}using System;using System.Collections.Generic;using System.Net.Http;using System.Text;using System.Text.Json;using System.Threading.Tasks;
class Program{ static async Task Main(string[] args) { var apiKey = "<your_api_key>"; var baseUrl = "https://api.oraicle.me/v1";
using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
var requestData = new { model = "deepseek-ai/DeepSeek-R1-0528", messages = new[] { new { role = "system", content = "You are a smarter assistant." }, new { role = "user", content = "In two sentences, what is an API key and why should I keep it secret?" } } };
var content = new StringContent( JsonSerializer.Serialize(requestData), Encoding.UTF8, "application/json");
var response = await client.PostAsync($"{baseUrl}/chat/completions", content); var responseBody = await response.Content.ReadAsStringAsync();
var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var result = JsonSerializer.Deserialize(responseBody, options);
Console.WriteLine(result.Choices[0].Message.Content); }}
class CompletionResponse{ public Choice[] Choices { get; set; }}
class Choice{ public Message Message { get; set; }}
class Message{ public string Content { get; set; }}package main
import ( "bytes" "encoding/json" "fmt" "io/ioutil" "net/http")
type ChatCompletionRequest struct { Model string `json:"model"` Messages []Message `json:"messages"`}
type Message struct { Role string `json:"role"` Content string `json:"content"`}
type ChatCompletionResponse struct { Choices []Choice `json:"choices"`}
type Choice struct { Message Message `json:"message"`}
func main() { apiKey := "<your_api_key>" baseURL := "https://api.oraicle.me/v1"
// Create request body reqBody := ChatCompletionRequest{ Model: "deepseek-ai/DeepSeek-R1-0528", Messages: []Message{ {Role: "system", Content: "You are a smarter assistant."}, {Role: "user", Content: "In two sentences, what is an API key and why should I keep it secret?"}, }, }
// Marshal the request body to JSON jsonData, err := json.Marshal(reqBody) if err != nil { fmt.Println("Error marshaling JSON:", err) return }
// Create HTTP request req, err := http.NewRequest("POST", baseURL+"/chat/completions", bytes.NewBuffer(jsonData)) if err != nil { fmt.Println("Error creating request:", err) return }
// Set headers req.Header.Set("Content-Type", "application/json") req.Header.Set("Authorization", "Bearer "+apiKey)
// Send the request client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close()
// Read the response body body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response:", err) return }
// Parse the response var result ChatCompletionResponse if err := json.Unmarshal(body, &result); err != nil { fmt.Println("Error parsing response:", err) return }
// Print the assistant's reply fmt.Println(result.Choices[0].Message.Content)}<?php$apiKey = '<your_api_key>';$baseUrl = 'https://api.oraicle.me/v1';
$data = [ 'model' => 'deepseek-ai/DeepSeek-R1-0528', 'messages' => [ [ 'role' => 'system', 'content' => 'You are a smarter assistant.' ], [ 'role' => 'user', 'content' => 'In two sentences, what is an API key and why should I keep it secret?' ] ]];
$headers = [ 'Content-Type: application/json', 'Authorization: Bearer ' . $apiKey];
$ch = curl_init($baseUrl . '/chat/completions');curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);curl_setopt($ch, CURLOPT_POST, true);curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);curl_close($ch);
if ($httpStatus === 200) { $responseData = json_decode($response, true); echo $responseData['choices'][0]['message']['content'];} else { echo "Error: " . $httpStatus . "\n" . $response;}?>Response:
{ "id": "chatcmpl-123abc456def", "object": "chat.completion", "created": 1677858242, "model": "deepseek-ai/DeepSeek-R1-0528", "usage": { "prompt_tokens": 31, "completion_tokens": 62, "total_tokens": 93 }, "choices": [ { "message": { "role": "assistant", "content": "An API key is a secret string that identifies your account when your code calls a service, so each request can be authorised and billed to you. Keep it out of client-side code and version control: anyone who has it can make requests, and spend, as you." }, "finish_reason": "stop", "index": 0 } ]}