Skip to main content

REST API

Direct HTTP access to the Ozwell API without any SDK. Use this when working with languages without an official SDK, or when you need full control over HTTP requests.

Base URL​

https://ozwellapi.os.mieweb.org/v1

Authentication​

Include your API key in the Authorization header:

Authorization: Bearer ozw_xxxxxxxxxxxxxxxx

Request Format​

All requests should include:

Content-Type: application/json
Authorization: Bearer YOUR_API_KEY

Chat Completions​

Create Chat Completion​

curl https://ozwellapi.os.mieweb.org/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}'

Response:

{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1699000000,
"model": "gpt-4",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 20,
"completion_tokens": 10,
"total_tokens": 30
}
}

With Parameters​

curl https://ozwellapi.os.mieweb.org/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Write a creative story"}
],
"temperature": 1.2,
"max_tokens": 500,
"top_p": 0.9,
"frequency_penalty": 0.5,
"presence_penalty": 0.5
}'

Streaming​

curl https://ozwellapi.os.mieweb.org/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [{"role": "user", "content": "Tell me a story"}],
"stream": true
}'

Streaming Response (Server-Sent Events):

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1699000000,"model":"gpt-4","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1699000000,"model":"gpt-4","choices":[{"index":0,"delta":{"content":"Once"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1699000000,"model":"gpt-4","choices":[{"index":0,"delta":{"content":" upon"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1699000000,"model":"gpt-4","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]

Function Calling​

curl https://ozwellapi.os.mieweb.org/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "What is the weather in Paris?"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "City name"
}
},
"required": ["location"]
}
}
}
],
"tool_choice": "auto"
}'

Response with Tool Call:

{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\": \"Paris\"}"
}
}
]
},
"finish_reason": "tool_calls"
}
]
}

Submit Tool Result​

curl https://ozwellapi.os.mieweb.org/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "What is the weather in Paris?"},
{
"role": "assistant",
"content": null,
"tool_calls": [{
"id": "call_abc123",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"location\": \"Paris\"}"}
}]
},
{
"role": "tool",
"tool_call_id": "call_abc123",
"content": "{\"temperature\": 18, \"condition\": \"Cloudy\"}"
}
]
}'

Embeddings​

Create Embedding​

curl https://ozwellapi.os.mieweb.org/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-d '{
"model": "text-embedding-ada-002",
"input": "Hello, world!"
}'

Response:

{
"object": "list",
"data": [
{
"object": "embedding",
"index": 0,
"embedding": [0.0023, -0.0092, 0.0156, ...]
}
],
"model": "text-embedding-ada-002",
"usage": {
"prompt_tokens": 3,
"total_tokens": 3
}
}

Batch Embeddings​

curl https://ozwellapi.os.mieweb.org/v1/embeddings \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-d '{
"model": "text-embedding-ada-002",
"input": [
"First document",
"Second document",
"Third document"
]
}'

Files​

Upload File​

curl https://ozwellapi.os.mieweb.org/v1/files \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-F "file=@document.pdf" \
-F "purpose=assistants"

Response:

{
"id": "file-abc123",
"object": "file",
"bytes": 1024000,
"created_at": 1699000000,
"filename": "document.pdf",
"purpose": "assistants"
}

List Files​

curl https://ozwellapi.os.mieweb.org/v1/files \
-H "Authorization: Bearer $OZWELL_API_KEY"

Retrieve File​

curl https://ozwellapi.os.mieweb.org/v1/files/file-abc123 \
-H "Authorization: Bearer $OZWELL_API_KEY"

Download File Content​

curl https://ozwellapi.os.mieweb.org/v1/files/file-abc123/content \
-H "Authorization: Bearer $OZWELL_API_KEY" \
-o downloaded.pdf

Delete File​

curl -X DELETE https://ozwellapi.os.mieweb.org/v1/files/file-abc123 \
-H "Authorization: Bearer $OZWELL_API_KEY"

Models​

List Models​

curl https://ozwellapi.os.mieweb.org/v1/models \
-H "Authorization: Bearer $OZWELL_API_KEY"

Response:

{
"object": "list",
"data": [
{
"id": "gpt-4",
"object": "model",
"created": 1699000000,
"owned_by": "openai"
},
{
"id": "gpt-3.5-turbo",
"object": "model",
"created": 1699000000,
"owned_by": "openai"
}
]
}

Retrieve Model​

curl https://ozwellapi.os.mieweb.org/v1/models/gpt-4 \
-H "Authorization: Bearer $OZWELL_API_KEY"

Error Responses​

Error Format​

{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key"
}
}

HTTP Status Codes​

CodeDescription
200Success
400Bad Request — Invalid parameters
401Unauthorized — Invalid or missing API key
403Forbidden — Insufficient permissions
404Not Found — Resource doesn't exist
429Rate Limited — Too many requests
500Server Error — Internal error

Rate Limit Headers​

X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1699000060
Retry-After: 30

Language Examples​

Go​

package main

import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)

type Message struct {
Role string `json:"role"`
Content string `json:"content"`
}

type ChatRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
}

type ChatResponse struct {
Choices []struct {
Message struct {
Content string `json:"content"`
} `json:"message"`
} `json:"choices"`
}

func main() {
reqBody := ChatRequest{
Model: "gpt-4",
Messages: []Message{
{Role: "user", Content: "Hello!"},
},
}

jsonBody, _ := json.Marshal(reqBody)

req, _ := http.NewRequest("POST", "https://ozwellapi.os.mieweb.org/v1/chat/completions", bytes.NewBuffer(jsonBody))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+os.Getenv("OZWELL_API_KEY"))

resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()

body, _ := io.ReadAll(resp.Body)

var chatResp ChatResponse
json.Unmarshal(body, &chatResp)

fmt.Println(chatResp.Choices[0].Message.Content)
}

Ruby​

require 'net/http'
require 'json'
require 'uri'

uri = URI('https://ozwellapi.os.mieweb.org/v1/chat/completions')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request['Content-Type'] = 'application/json'
request['Authorization'] = "Bearer #{ENV['OZWELL_API_KEY']}"
request.body = {
model: 'gpt-4',
messages: [
{ role: 'user', content: 'Hello!' }
]
}.to_json

response = http.request(request)
data = JSON.parse(response.body)

puts data['choices'][0]['message']['content']

PHP​

<?php

$apiKey = getenv('OZWELL_API_KEY');

$data = [
'model' => 'gpt-4',
'messages' => [
['role' => 'user', 'content' => 'Hello!']
]
];

$ch = curl_init('https://ozwellapi.os.mieweb.org/v1/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, [
'Content-Type: application/json',
'Authorization: Bearer ' . $apiKey
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
echo $result['choices'][0]['message']['content'];

Java​

import java.net.http.*;
import java.net.URI;

public class OzwellExample {
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("OZWELL_API_KEY");

String body = """
{
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Hello!"}
]
}
""";

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://ozwellapi.os.mieweb.org/v1/chat/completions"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + apiKey)
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();

HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());

System.out.println(response.body());
}
}

Rust​

use reqwest::header::{AUTHORIZATION, CONTENT_TYPE};
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("OZWELL_API_KEY")?;

let client = reqwest::Client::new();

let response = client
.post("https://ozwellapi.os.mieweb.org/v1/chat/completions")
.header(CONTENT_TYPE, "application/json")
.header(AUTHORIZATION, format!("Bearer {}", api_key))
.json(&json!({
"model": "gpt-4",
"messages": [
{"role": "user", "content": "Hello!"}
]
}))
.send()
.await?;

let data: serde_json::Value = response.json().await?;
println!("{}", data["choices"][0]["message"]["content"]);

Ok(())
}

C#​

using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;

var apiKey = Environment.GetEnvironmentVariable("OZWELL_API_KEY");

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", apiKey);

var requestBody = new {
model = "gpt-4",
messages = new[] {
new { role = "user", content = "Hello!" }
}
};

var response = await client.PostAsync(
"https://ozwellapi.os.mieweb.org/v1/chat/completions",
new StringContent(
JsonSerializer.Serialize(requestBody),
Encoding.UTF8,
"application/json"
)
);

var responseBody = await response.Content.ReadAsStringAsync();
var data = JsonDocument.Parse(responseBody);

Console.WriteLine(
data.RootElement
.GetProperty("choices")[0]
.GetProperty("message")
.GetProperty("content")
.GetString()
);

See Also​