Skip to content

Quick Start Guide

Get up and running with Voidon takes less than 5 minutes! This guide will help you make your first API call and understand the core features.

Prerequisites

Before you begin, make sure you have:

  • A Voidon API key (sign up at voidon.astramind.ai)
  • A programming language with at least a http client, better if it has also a openai package (i.e: Python 3.8+, Node.js 16+, ...)
  • Basic familiarity with REST APIs

Step 1: API Keys Setup

  1. Visit the Voidon Dashboard
  2. Sign up or log in to your account
  3. On the main page you'll see your private API key, this is what you'll use to make the API calls to the service
  4. Click on the Settings button in the top-right corner, then click on Security and set the External API keys of the services you want to use
  5. Copy your Primary API key (keep it secure!)

Keep Your API Key Safe

Your API key provides access to your Voidon account. Never share it publicly or commit it to version control. In case you leak it change it by recreating it immediately

Register all the apis for the services you want to use

At the moment Voidon does not provide you with default APIs, so you'll need to add every API key you intend to use, if you don't Voidon will not use unset providers by default

Voidon is compatible with existing OpenAI SDKs, so you can use libraries you're already familiar with:

Bash
pip install openai
Bash
npm install openai

Check for a openai package for your library of choice, don't worry if you don't find one, you can still use a simple http client.

Step 3: Make Your First Request

Bash
1
2
3
4
5
6
7
8
9
curl -X POST https://api.voidon.astramind.ai/v1/chat/completions \
  -H "Authorization: Bearer your-voidon-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'
Python
import openai


client = openai.OpenAI(
    api_key="your-voidon-api-key",
    base_url="https://api.voidon.astramind.ai/v1"
)

response = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response.choices.message.content)
Python
import requests
import json

API_KEY = "your-voidon-api-key"
API_URL = "https://api.voidon.astramind.ai/v1/chat/completions"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

payload = {
    "model": "auto",
    "messages": [{"role": "user", "content": "Hello!"}]
}

response = requests.post(API_URL, headers=headers, data=json.dumps(payload))

if response.status_code == 200:
    print(response.json()['choices']['message']['content'])
else:
    print(f"Error: {response.status_code} - {response.text}")
JavaScript
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const response = await openai.chat.completions.create({
        model: 'auto',
        messages: [{ role: 'user', content: 'Hello!' }],
    });
    console.log(response.choices.message.content);
}

main();
JavaScript
const apiKey = 'your-voidon-api-key';
const apiUrl = 'https://api.voidon.astramind.ai/v1/chat/completions';

const payload = {
    model: 'auto',
    messages: [{ role: 'user', content: 'Hello!' }],
};

fetch(apiUrl, {
    method: 'POST',
    headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => {
    console.log(data.choices.message.content);
})
.catch(error => console.error('Error:', error));
TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const response = await openai.chat.completions.create({
        model: 'auto',
        messages: [{ role: 'user', content: 'Hello!' }],
    });
    console.log(response.choices?.message?.content);
}

main();
TypeScript
const apiKey: string = 'your-voidon-api-key';
const apiUrl: string = 'https://api.voidon.astramind.ai/v1/chat/completions';

interface Message {
    role: 'user' | 'assistant' | 'system';
    content: string;
}

const payload: { model: string; messages: Message[] } = {
    model: 'auto',
    messages: [{ role: 'user', content: 'Hello!' }],
};

async function main() {
    try {
        const response = await fetch(apiUrl, {
            method: 'POST',
            headers: {
                'Authorization': `Bearer ${apiKey}`,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(payload)
        });

        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }

        const data = await response.json();
        console.log(data.choices?.message?.content);
    } catch (error) {
        console.error('Error:', error);
    }
}

main();
PHP
<?php
require_once __DIR__ . '/vendor/autoload.php';

$client = OpenAI::factory()
    ->withApiKey('your-voidon-api-key')
    ->withBaseUri('api.voidon.astramind.ai/v1') 
    ->make();

$response = $client->chat()->create([
    'model' => 'auto',
    'messages' => [
        ['role' => 'user', 'content' => 'Hello!'],
    ],
]);

echo $response->choices->message->content; // Oggetto
// echo $response['choices']['message']['content']; // Array
PHP
<?php

$apiKey = 'your-voidon-api-key';
$url = 'https://api.voidon.astramind.ai/v1/chat/completions';

$payload = json_encode([
    'model' => 'auto',
    'messages' => [
        ['role' => 'user', 'content' => 'Hello!']
    ]
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey
]);

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

$data = json_decode($response, true);
echo $data['choices']['message']['content'];
Go
package main

import (
    "context"
    "fmt"
    "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("your-voidon-api-key")
    config.BaseURL = "https://api.voidon.astramind.ai/v1"
    client := openai.NewClientWithConfig(config)

    resp, err := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model: "auto",
            Messages: []openai.ChatCompletionMessage{
                {Role: openai.ChatMessageRoleUser, Content: "Hello!"},
            },
        },
    )
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Println(resp.Choices.Message.Content)
}
Go
package main

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

func main() {
    apiKey := "your-voidon-api-key"
    url := "https://api.voidon.astramind.ai/v1/chat/completions"

    requestBody, _ := json.Marshal(map[string]interface{}{
        "model": "auto",
        "messages": []map[string]string{
            {"role": "user", "content": "Hello!"},
        },
    })

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

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

    var result map[string]interface{}
    json.Unmarshal(body, &result)


    choices := result["choices"].([]interface{})
    firstChoice := choices.(map[string]interface{})
    message := firstChoice["message"].(map[string]interface{})
    content := message["content"].(string)

    fmt.Println(content)
}
Java
// Dep: com.theokanning.openai-service
// Note: configuration of base_url with this lib requires
// the creation of a custom Retrofit instance 
import com.theokanning.openai.completion.chat.ChatCompletionRequest;
import com.theokanning.openai.completion.chat.ChatMessage;
import com.theokanning.openai.service.OpenAiService;
import java.util.List;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.jackson.JacksonConverterFactory;
import java.time.Duration;

public class VoidonExample {
    public static void main(String[] args) {
        String apiKey = "your-voidon-api-key";
        String baseUrl = "https://api.voidon.astramind.ai/"; // La v1 è nel path dell'endpoint

        // Configurazione client avanzata per impostare il Base URL
        OkHttpClient client = OpenAiService.defaultClient(apiKey, Duration.ofSeconds(60))
                .newBuilder()
                .build();
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .client(client)
                .addConverterFactory(JacksonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();

        OpenAiService service = new OpenAiService(retrofit.create(com.theokanning.openai.service.OpenAiApi.class));

        ChatCompletionRequest request = ChatCompletionRequest.builder()
            .model("auto")
            .messages(List.of(new ChatMessage("user", "Hello!")))
            .build();

        var response = service.createChatCompletion(request);
        System.out.println(response.getChoices().get(0).getMessage().getContent());
    }
}
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.IOException;

public class VoidonHttpExample {
    public static void main(String[] args) throws IOException, InterruptedException {
        String apiKey = "your-voidon-api-key";
        String url = "https://api.voidon.astramind.ai/v1/chat/completions";

        String jsonPayload = """
        {
            "model": "auto",
            "messages": [{"role": "user", "content": "Hello!"}]
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
                .build();

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

        // Semplice parsing del JSON per l'esempio
        String responseBody = response.body();
        String content = responseBody.split("\"content\":\"").split("\"");
        System.out.println(content);
    }
}
Ruby
require 'openai'

client = OpenAI::Client.new(
  access_token: 'your-voidon-api-key',
  uri_base: 'https://api.voidon.astramind.ai/' # La libreria aggiunge /v1
)

response = client.chat(
  parameters: {
    model: 'auto',
    messages: [{ role: 'user', content: 'Hello!' }]
  }
)

puts response.dig('choices', 0, 'message', 'content')
Ruby
require 'uri'
require 'net/http'
require 'json'

api_key = 'your-voidon-api-key'
uri = URI('https://api.voidon.astramind.ai/v1/chat/completions')

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

request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request.body = JSON.dump({
  "model": "auto",
  "messages": [{ "role": "user", "content": "Hello!" }]
})

response = http.request(request)

response_data = JSON.parse(response.read_body)
puts response_data.dig('choices', 0, 'message', 'content')

Step 4: Try Advanced Features

Use Model Groups

You can use or create custom selection groups via the dashboard and then use them in the api by simply doing assigning [chosen-model-group]/auto to the model. Groups limits the model choices only between models that are chosen.

More info here.

Bash
1
2
3
4
5
6
7
8
9
curl -X POST https://api.voidon.astramind.ai/v1/chat/completions \
  -H "Authorization: Bearer your-voidon-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "[chosen-model-group]/auto",
    "messages": [
      {"role": "user", "content": "Hello!"}
    ]
  }'
Python
import openai


client = openai.OpenAI(
    api_key="your-voidon-api-key",
    base_url="https://api.voidon.astramind.ai/v1"
)

response = client.chat.completions.create(
    model="[chosen-model-group]/auto",
    messages=[{"role": "user", "content": "Hello!"}]
)

print(response.choices.message.content)
Python
import requests
import json

API_KEY = "your-voidon-api-key"
API_URL = "https://api.voidon.astramind.ai/v1/chat/completions"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

payload = {
    "model": "[chosen-model-group]/auto",
    "messages": [{"role": "user", "content": "Hello!"}]
}

response = requests.post(API_URL, headers=headers, data=json.dumps(payload))

if response.status_code == 200:
    print(response.json()['choices']['message']['content'])
else:
    print(f"Error: {response.status_code} - {response.text}")
JavaScript
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const response = await openai.chat.completions.create({
        model: '[chosen-model-group]/auto',
        messages: [{ role: 'user', content: 'Hello!' }],
    });
    console.log(response.choices.message.content);
}

main();
JavaScript
const apiKey = 'your-voidon-api-key';
const apiUrl = 'https://api.voidon.astramind.ai/v1/chat/completions';

const payload = {
    model: '[chosen-model-group]/auto',
    messages: [{ role: 'user', content: 'Hello!' }],
};

fetch(apiUrl, {
    method: 'POST',
    headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => {
    console.log(data.choices.message.content);
})
.catch(error => console.error('Error:', error));
TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const response = await openai.chat.completions.create({
        model: '[chosen-model-group]/auto',
        messages: [{ role: 'user', content: 'Hello!' }],
    });
    console.log(response.choices?.message?.content);
}

main();
TypeScript
const apiKey: string = 'your-voidon-api-key';
const apiUrl: string = 'https://api.voidon.astramind.ai/v1/chat/completions';

interface Message {
    role: 'user' | 'assistant' | 'system';
    content: string;
}

const payload: { model: string; messages: Message[] } = {
    model: '[chosen-model-group]/auto',
    messages: [{ role: 'user', content: 'Hello!' }],
};

async function main() {
    try {
        const response = await fetch(apiUrl, {
            method: 'POST',
            headers: {
                'Authorization': `Bearer ${apiKey}`,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(payload)
        });

        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }

        const data = await response.json();
        console.log(data.choices?.message?.content);
    } catch (error) {
        console.error('Error:', error);
    }
}

main();
PHP
<?php
require_once __DIR__ . '/vendor/[chosen-model-group]/autoload.php';

$client = OpenAI::factory()
    ->withApiKey('your-voidon-api-key')
    ->withBaseUri('api.voidon.astramind.ai/v1') 
    ->make();

$response = $client->chat()->create([
    'model' => '[chosen-model-group]/auto',
    'messages' => [
        ['role' => 'user', 'content' => 'Hello!'],
    ],
]);

echo $response->choices->message->content; // Oggetto
// echo $response['choices']['message']['content']; // Array
PHP
<?php

$apiKey = 'your-voidon-api-key';
$url = 'https://api.voidon.astramind.ai/v1/chat/completions';

$payload = json_encode([
    'model' => '[chosen-model-group]/auto',
    'messages' => [
        ['role' => 'user', 'content' => 'Hello!']
    ]
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey
]);

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

$data = json_decode($response, true);
echo $data['choices']['message']['content'];
Go
package main

import (
    "context"
    "fmt"
    "github.com/sashabaranov/go-openai"
)

func main() {
    config := openai.DefaultConfig("your-voidon-api-key")
    config.BaseURL = "https://api.voidon.astramind.ai/v1"
    client := openai.NewClientWithConfig(config)

    resp, err := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model: "[chosen-model-group]/auto",
            Messages: []openai.ChatCompletionMessage{
                {Role: openai.ChatMessageRoleUser, Content: "Hello!"},
            },
        },
    )
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Println(resp.Choices.Message.Content)
}
Go
package main

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

func main() {
    apiKey := "your-voidon-api-key"
    url := "https://api.voidon.astramind.ai/v1/chat/completions"

    requestBody, _ := json.Marshal(map[string]interface{}{
        "model": "[chosen-model-group]/auto",
        "messages": []map[string]string{
            {"role": "user", "content": "Hello!"},
        },
    })

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

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

    var result map[string]interface{}
    json.Unmarshal(body, &result)


    choices := result["choices"].([]interface{})
    firstChoice := choices.(map[string]interface{})
    message := firstChoice["message"].(map[string]interface{})
    content := message["content"].(string)

    fmt.Println(content)
}
Java
// Dep: com.theokanning.openai-service
// Note: configuration of base_url with this lib requires
// the creation of a custom Retrofit instance 
import com.theokanning.openai.completion.chat.ChatCompletionRequest;
import com.theokanning.openai.completion.chat.ChatMessage;
import com.theokanning.openai.service.OpenAiService;
import java.util.List;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.jackson.JacksonConverterFactory;
import java.time.Duration;

public class VoidonExample {
    public static void main(String[] args) {
        String apiKey = "your-voidon-api-key";
        String baseUrl = "https://api.voidon.astramind.ai/"; // La v1 è nel path dell'endpoint

        // Configurazione client avanzata per impostare il Base URL
        OkHttpClient client = OpenAiService.defaultClient(apiKey, Duration.ofSeconds(60))
                .newBuilder()
                .build();
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .client(client)
                .addConverterFactory(JacksonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();

        OpenAiService service = new OpenAiService(retrofit.create(com.theokanning.openai.service.OpenAiApi.class));

        ChatCompletionRequest request = ChatCompletionRequest.builder()
            .model("[chosen-model-group]/auto")
            .messages(List.of(new ChatMessage("user", "Hello!")))
            .build();

        var response = service.createChatCompletion(request);
        System.out.println(response.getChoices().get(0).getMessage().getContent());
    }
}
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.IOException;

public class VoidonHttpExample {
    public static void main(String[] args) throws IOException, InterruptedException {
        String apiKey = "your-voidon-api-key";
        String url = "https://api.voidon.astramind.ai/v1/chat/completions";

        String jsonPayload = """
        {
            "model": "[chosen-model-group]/auto",
            "messages": [{"role": "user", "content": "Hello!"}]
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
                .build();

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

        // Semplice parsing del JSON per l'esempio
        String responseBody = response.body();
        String content = responseBody.split("\"content\":\"").split("\"");
        System.out.println(content);
    }
}
Ruby
require 'openai'

client = OpenAI::Client.new(
  access_token: 'your-voidon-api-key',
  uri_base: 'https://api.voidon.astramind.ai/' # La libreria aggiunge /v1
)

response = client.chat(
  parameters: {
    model: '[chosen-model-group]/auto',
    messages: [{ role: 'user', content: 'Hello!' }]
  }
)

puts response.dig('choices', 0, 'message', 'content')
Ruby
require 'uri'
require 'net/http'
require 'json'

api_key = 'your-voidon-api-key'
uri = URI('https://api.voidon.astramind.ai/v1/chat/completions')

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

request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request.body = JSON.dump({
  "model": "[chosen-model-group]/auto",
  "messages": [{ "role": "user", "content": "Hello!" }]
})

response = http.request(request)

response_data = JSON.parse(response.read_body)
puts response_data.dig('choices', 0, 'message', 'content')

Privacy-Preserving Anonymization

Request anonymization is ON by default

If you want you can set the default option to OFF or you can configure the anonymization types in the profile settings

Enable automatic PII removal for sensitive content:

Bash
curl -X POST https://api.voidon.astramind.ai/v1/chat/completions \
  -H "Authorization: Bearer your-voidon-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [
      {"role": "user", "content": "My name is John Smith and my email is john.smith@example.com. Help me write a resume."}
    ],
    "enable_anonymization": true
  }'
Python
import openai

client = openai.OpenAI(
    api_key="your-voidon-api-key",
    base_url="https://api.voidon.astramind.ai/v1"
)

response = client.chat.completions.create(
    model="auto",
    messages=[{
        "role": "user",
        "content": "My name is John Smith and my email is john.smith@example.com. Help me write a resume."
    }],
    extra_body={
        "enable_anonymization": True  # 🔒 Automatic PII removal
    }
)

print(response.choices[0].message.content)
Python
import requests
import json

API_KEY = "your-voidon-api-key"
API_URL = "https://api.voidon.astramind.ai/v1/chat/completions"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

payload = {
    "model": "auto",
    "messages": [{
        "role": "user",
        "content": "My name is John Smith and my email is john.smith@example.com. Help me write a resume."
    }],
    "enable_anonymization": True  # 🔒 Automatic PII removal
}

response = requests.post(API_URL, headers=headers, data=json.dumps(payload))

if response.status_code == 200:
    print(response.json()['choices'][0]['message']['content'])
else:
    print(f"Error: {response.status_code} - {response.text}")
JavaScript
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const response = await openai.chat.completions.create({
        model: 'auto',
        messages: [{ 
            role: 'user', 
            content: 'My name is John Smith and my email is john.smith@example.com. Help me write a resume.' 
        }],
        // @ts-expect-error - This is a custom parameter
        enable_anonymization: true, // 🔒 Automatic PII removal
    });
    console.log(response.choices[0].message.content);
}

main();
JavaScript
const apiKey = 'your-voidon-api-key';
const apiUrl = 'https://api.voidon.astramind.ai/v1/chat/completions';

const payload = {
    model: 'auto',
    messages: [{ 
        role: 'user', 
        content: 'My name is John Smith and my email is john.smith@example.com. Help me write a resume.' 
    }],
    enable_anonymization: true, // 🔒 Automatic PII removal
};

fetch(apiUrl, {
    method: 'POST',
    headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => {
    console.log(data.choices[0].message.content);
})
.catch(error => console.error('Error:', error));
TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const response = await openai.chat.completions.create({
        model: 'auto',
        messages: [{ 
            role: 'user', 
            content: 'My name is John Smith and my email is john.smith@example.com. Help me write a resume.' 
        }],
        // @ts-expect-error - This is a custom parameter
        enable_anonymization: true, // 🔒 Automatic PII removal
    });
    console.log(response.choices[0]?.message?.content);
}

main();
TypeScript
const apiKey: string = 'your-voidon-api-key';
const apiUrl: string = 'https://api.voidon.astramind.ai/v1/chat/completions';

interface Message {
    role: 'user' | 'assistant' | 'system';
    content: string;
}

interface Payload {
    model: string;
    messages: Message[];
    enable_anonymization?: boolean; // 🔒 Automatic PII removal
}

const payload: Payload = {
    model: 'auto',
    messages: [{ 
        role: 'user', 
        content: 'My name is John Smith and my email is john.smith@example.com. Help me write a resume.' 
    }],
    enable_anonymization: true,
};

async function main() {
    try {
        const response = await fetch(apiUrl, {
            method: 'POST',
            headers: {
                'Authorization': `Bearer ${apiKey}`,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(payload)
        });

        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }

        const data = await response.json();
        console.log(data.choices[0]?.message?.content);
    } catch (error) {
        console.error('Error:', error);
    }
}

main();
PHP
<?php
require_once __DIR__ . '/vendor/autoload.php';

$client = OpenAI::factory()
    ->withApiKey('your-voidon-api-key')
    ->withBaseUri('api.voidon.astramind.ai/v1') 
    ->make();

$response = $client->chat()->create([
    'model' => 'auto',
    'messages' => [
        ['role' => 'user', 'content' => 'My name is John Smith and my email is john.smith@example.com. Help me write a resume.'],
    ],
    'enable_anonymization' => true, // 🔒 Automatic PII removal
]);

echo $response->choices[0]->message->content; // Oggetto
// echo $response['choices'][0]['message']['content']; // Array
PHP
<?php

$apiKey = 'your-voidon-api-key';
$url = 'https://api.voidon.astramind.ai/v1/chat/completions';

$payload = json_encode([
    'model' => 'auto',
    'messages' => [
        ['role' => 'user', 'content' => 'My name is John Smith and my email is john.smith@example.com. Help me write a resume.']
    ],
    'enable_anonymization' => true // 🔒 Automatic PII removal
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey
]);

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

$data = json_decode($response, true);
echo $data['choices'][0]['message']['content'];
Go
package main

import (
    "context"
    "fmt"
    "github.com/sashabaranov/go-openai"
)

func main() {
    // Note: The standard go-openai client may not support custom top-level parameters
    // like "enable_anonymization". Using the direct HTTP client is the recommended
    // approach for custom API extensions.

    config := openai.DefaultConfig("your-voidon-api-key")
    config.BaseURL = "https://api.voidon.astramind.ai/v1"
    client := openai.NewClientWithConfig(config)

    resp, err := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model: "auto",
            Messages: []openai.ChatCompletionMessage{
                {
                    Role: openai.ChatMessageRoleUser, 
                    Content: "My name is John Smith and my email is john.smith@example.com. Help me write a resume.",
                },
            },
        },
    )
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Println(resp.Choices[0].Message.Content)
}
Go
package main

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

func main() {
    apiKey := "your-voidon-api-key"
    url := "https://api.voidon.astramind.ai/v1/chat/completions"

    requestBody, _ := json.Marshal(map[string]interface{}{
        "model": "auto",
        "messages": []map[string]string{
            {"role": "user", "content": "My name is John Smith and my email is john.smith@example.com. Help me write a resume."},
        },
        "enable_anonymization": true, // 🔒 Automatic PII removal
    })

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

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

    var result map[string]interface{}
    json.Unmarshal(body, &result)

    choices := result["choices"].([]interface{})
    firstChoice := choices[0].(map[string]interface{})
    message := firstChoice["message"].(map[string]interface{})
    content := message["content"].(string)

    fmt.Println(content)
}
Java
// Dep: com.theokanning.openai-service
import com.theokanning.openai.completion.chat.ChatCompletionRequest;
import com.theokanning.openai.completion.chat.ChatMessage;
import com.theokanning.openai.service.OpenAiService;
import java.util.List;

public class VoidonExample {
    public static void main(String[] args) {
        // Note: The standard com.theokanning.openai-service may not support 
        // custom top-level parameters like "enable_anonymization". 
        // Using a direct HTTP client is the recommended approach for such features.

        OpenAiService service = new OpenAiService("your-voidon-api-key");

        ChatCompletionRequest request = ChatCompletionRequest.builder()
            .model("auto")
            .messages(List.of(new ChatMessage(
                "user", 
                "My name is John Smith and my email is john.smith@example.com. Help me write a resume."
            )))
            .build();

        // The base URL must be configured via a custom Retrofit instance
        // for non-standard endpoints. The HTTP client example is more direct.
        // var response = service.createChatCompletion(request);
        // System.out.println(response.getChoices().get(0).getMessage().getContent());
    }
}
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.IOException;
import com.google.gson.Gson; // Example using Gson for parsing
import com.google.gson.JsonObject;

public class VoidonHttpExample {
    public static void main(String[] args) throws IOException, InterruptedException {
        String apiKey = "your-voidon-api-key";
        String url = "https://api.voidon.astramind.ai/v1/chat/completions";

        String jsonPayload = """
        {
            "model": "auto",
            "messages": [{"role": "user", "content": "My name is John Smith and my email is john.smith@example.com. Help me write a resume."}],
            "enable_anonymization": true
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
                .build();

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

        // Using Gson for more reliable JSON parsing
        JsonObject jsonResponse = new Gson().fromJson(response.body(), JsonObject.class);
        String content = jsonResponse.getAsJsonArray("choices")
                                     .get(0).getAsJsonObject()
                                     .getAsJsonObject("message")
                                     .get("content").getAsString();

        System.out.println(content);
    }
}
Ruby
require 'openai'

client = OpenAI::Client.new(
  access_token: 'your-voidon-api-key',
  uri_base: 'https://api.voidon.astramind.ai/' # The library adds /v1
)

response = client.chat(
  parameters: {
    model: 'auto',
    messages: [{ 
        role: 'user', 
        content: 'My name is John Smith and my email is john.smith@example.com. Help me write a resume.' 
    }],
    enable_anonymization: true # 🔒 Automatic PII removal
  }
)

puts response.dig('choices', 0, 'message', 'content')
Ruby
require 'uri'
require 'net/http'
require 'json'

api_key = 'your-voidon-api-key'
uri = URI('https://api.voidon.astramind.ai/v1/chat/completions')

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

request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request.body = JSON.dump({
  "model" => "auto",
  "messages" => [{ 
      "role" => "user", 
      "content" => "My name is John Smith and my email is john.smith@example.com. Help me write a resume." 
  }],
  "enable_anonymization" => true # 🔒 Automatic PII removal
})

response = http.request(request)

response_data = JSON.parse(response.read_body)
puts response_data.dig('choices', 0, 'message', 'content')

Document Processing

Process documents directly in your chat:

Document format

Many formats are supported but you shuld always pass them as inline data. They're anonimized if the request requires anonymization.

For more infoormations on the supported formats please check the Document page

For these examples to work, you need to have a file named resume.pdf in the same directory where you run the code.

Bash
# First, encode the PDF in Base64 and store it in a variable
pdf_data=$(base64 -w 0 resume.pdf)

# Then, make the API call with the Base64 data embedded in the JSON
curl -X POST https://api.voidon.astramind.ai/v1/chat/completions \
  -H "Authorization: Bearer your-voidon-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [{
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "Summarize this resume:"
            },
            {
                "type": "file",
                "file": {
                    "url": "data:application/pdf;base64,'"$pdf_data"'"
                }
            }
        ]
    }]
  }'
Python
import openai
import base64

# Read the PDF file and encode it in Base64
with open("resume.pdf", "rb") as file:
    pdf_data = base64.b64encode(file.read()).decode('utf-8')

client = openai.OpenAI(
    api_key="your-voidon-api-key",
    base_url="https://api.voidon.astramind.ai/v1"
)

response = client.chat.completions.create(
    model="auto",
    messages=[{
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "Summarize this resume:"
            },
            {
                "type": "file",
                "file": {
                    "url": f"data:application/pdf;base64,{pdf_data}"
                }
            }
        ]
    }]
)

print(response.choices[0].message.content)
Python
import requests
import json
import base64

API_KEY = "your-voidon-api-key"
API_URL = "https://api.voidon.astramind.ai/v1/chat/completions"

# Read the PDF file and encode it in Base64
with open("resume.pdf", "rb") as file:
    pdf_data = base64.b64encode(file.read()).decode('utf-8')

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

payload = {
    "model": "auto",
    "messages": [{
        "role": "user",
        "content": [
            {
                "type": "text",
                "text": "Summarize this resume:"
            },
            {
                "type": "file",
                "file": {
                    "url": f"data:application/pdf;base64,{pdf_data}"
                }
            }
        ]
    }]
}

response = requests.post(API_URL, headers=headers, data=json.dumps(payload))

if response.status_code == 200:
    print(response.json()['choices'][0]['message']['content'])
else:
    print(f"Error: {response.status_code} - {response.text}")
JavaScript
import OpenAI from 'openai';
import fs from 'fs';

// Read the PDF file and encode it in Base64
const pdfData = fs.readFileSync('resume.pdf').toString('base64');

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const response = await openai.chat.completions.create({
        model: 'auto',
        messages: [{
            role: 'user',
            content: [
                {
                    type: 'text',
                    text: 'Summarize this resume:'
                },
                {
                    type: 'file',
                    file: {
                        url: `data:application/pdf;base64,${pdfData}`
                    }
                }
            ]
        }],
    });
    console.log(response.choices[0].message.content);
}

main();
JavaScript
import fs from 'fs';

const apiKey = 'your-voidon-api-key';
const apiUrl = 'https://api.voidon.astramind.ai/v1/chat/completions';

// Read the PDF file and encode it in Base64
const pdfData = fs.readFileSync('resume.pdf').toString('base64');

const payload = {
    model: 'auto',
    messages: [{
        role: 'user',
        content: [
            {
                type: 'text',
                text: 'Summarize this resume:'
            },
            {
                type: 'file',
                file: {
                    url: `data:application/pdf;base64,${pdfData}`
                }
            }
        ]
    }],
};

fetch(apiUrl, {
    method: 'POST',
    headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
    },
    body: JSON.stringify(payload)
})
.then(res => res.json())
.then(data => {
    console.log(data.choices[0].message.content);
})
.catch(error => console.error('Error:', error));
TypeScript
import OpenAI from 'openai';
import * as fs from 'fs';

// Read the PDF file and encode it in Base64
const pdfData = fs.readFileSync('resume.pdf').toString('base64');

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

// Define a more flexible type for the message content
type MessageContent = (
    OpenAI.Chat.Completions.ChatCompletionContentPart & 
    { type: 'file'; file?: { url: string } }
)[];

async function main() {
    const response = await openai.chat.completions.create({
        model: 'auto',
        messages: [{
            role: 'user',
            content: [
                {
                    type: 'text',
                    text: 'Summarize this resume:'
                },
                {
                    type: 'file',
                    file: {
                        url: `data:application/pdf;base64,${pdfData}`
                    }
                }
            ] as unknown as MessageContent, // Cast to custom type
        }],
    });
    console.log(response.choices[0]?.message?.content);
}

main();
TypeScript
import * as fs from 'fs';

const apiKey: string = 'your-voidon-api-key';
const apiUrl: string = 'https://api.voidon.astramind.ai/v1/chat/completions';

// Read the PDF file and encode it in Base64
const pdfData: string = fs.readFileSync('resume.pdf').toString('base64');

interface MessageContentPart {
    type: 'text' | 'file';
    text?: string;
    file?: {
        url: string;
    };
}

interface Message {
    role: 'user' | 'assistant' | 'system';
    content: MessageContentPart[];
}

const payload: { model: string; messages: Message[] } = {
    model: 'auto',
    messages: [{
        role: 'user',
        content: [
            {
                type: 'text',
                text: 'Summarize this resume:'
            },
            {
                type: 'file',
                file: {
                    url: `data:application/pdf;base64,${pdfData}`
                }
            }
        ]
    }],
};

async function main() {
    try {
        const response = await fetch(apiUrl, {
            method: 'POST',
            headers: {
                'Authorization': `Bearer ${apiKey}`,
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(payload)
        });

        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }

        const data = await response.json();
        console.log(data.choices[0]?.message?.content);
    } catch (error) {
        console.error('Error:', error);
    }
}

main();
PHP
<?php
require_once __DIR__ . '/vendor/autoload.php';

// Read the PDF file and encode it in Base64
$pdfData = base64_encode(file_get_contents('resume.pdf'));

$client = OpenAI::factory()
    ->withApiKey('your-voidon-api-key')
    ->withBaseUri('api.voidon.astramind.ai/v1') 
    ->make();

$response = $client->chat()->create([
    'model' => 'auto',
    'messages' => [
        [
            'role' => 'user', 
            'content' => [
                ['type' => 'text', 'text' => 'Summarize this resume:'],
                ['type' => 'file', 'file' => ['url' => 'data:application/pdf;base64,' . $pdfData]]
            ]
        ],
    ],
]);

echo $response->choices[0]->message->content;
PHP
<?php

$apiKey = 'your-voidon-api-key';
$url = 'https://api.voidon.astramind.ai/v1/chat/completions';

// Read the PDF file and encode it in Base64
$pdfData = base64_encode(file_get_contents('resume.pdf'));

$payload = json_encode([
    'model' => 'auto',
    'messages' => [
        [
            'role' => 'user', 
            'content' => [
                ['type' => 'text', 'text' => 'Summarize this resume:'],
                ['type' => 'file', 'file' => ['url' => 'data:application/pdf;base64,' . $pdfData]]
            ]
        ]
    ]
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey
]);

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

$data = json_decode($response, true);
echo $data['choices'][0]['message']['content'];
Go
package main

import (
    "context"
    "encoding/base64"
    "fmt"
    "io/ioutil"
    "github.com/sashabaranov/go-openai"
)

func main() {
    // Note: The go-openai client is designed for OpenAI's API spec, which uses
    // 'image_url' for multimodal content. A custom 'file' type might not be
    // directly supported. The HTTP client approach is more reliable for custom APIs.

    // Read the PDF file and encode it in Base64
    pdfBytes, err := ioutil.ReadFile("resume.pdf")
    if err != nil {
        panic(err)
    }
    pdfData := base64.StdEncoding.EncodeToString(pdfBytes)

    config := openai.DefaultConfig("your-voidon-api-key")
    config.BaseURL = "https://api.voidon.astramind.ai/v1"
    client := openai.NewClientWithConfig(config)

    resp, err := client.CreateChatCompletion(
        context.Background(),
        openai.ChatCompletionRequest{
            Model: "auto",
            Messages: []openai.ChatCompletionMessage{
                {
                    Role: openai.ChatMessageRoleUser,
                    MultiContent: []openai.ChatMessagePart{
                        {
                            Type: openai.ChatMessagePartTypeText,
                            Text: "Summarize this resume:",
                        },
                        {
                            // We use ImageURL here as it's the structure the library provides for multimodal content.
                            // The custom API must be compatible with this structure for it to work.
                            Type: openai.ChatMessagePartTypeImageURL,
                            ImageURL: &openai.ChatMessageImageURL{
                                URL: fmt.Sprintf("data:application/pdf;base64,%s", pdfData),
                            },
                        },
                    },
                },
            },
        },
    )
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }
    fmt.Println(resp.Choices[0].Message.Content)
}
Go
package main

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

func main() {
    apiKey := "your-voidon-api-key"
    url := "https://api.voidon.astramind.ai/v1/chat/completions"

    // Read the PDF file and encode it in Base64
    pdfBytes, err := ioutil.ReadFile("resume.pdf")
    if err != nil {
        panic(err)
    }
    pdfData := base64.StdEncoding.EncodeToString(pdfBytes)

    requestBody, _ := json.Marshal(map[string]interface{}{
        "model": "auto",
        "messages": []map[string]interface{}{
            {
                "role": "user",
                "content": []map[string]interface{}{
                    {
                        "type": "text",
                        "text": "Summarize this resume:",
                    },
                    {
                        "type": "file",
                        "file": map[string]string{
                            "url": fmt.Sprintf("data:application/pdf;base64,%s", pdfData),
                        },
                    },
                },
            },
        },
    })

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

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

    var result map[string]interface{}
    json.Unmarshal(body, &result)

    choices := result["choices"].([]interface{})
    firstChoice := choices[0].(map[string]interface{})
    message := firstChoice["message"].(map[string]interface{})
    content := message["content"].(string)

    fmt.Println(content)
}
Java
// Note: The com.theokanning.openai-service library is strictly typed for OpenAI's
// API. It does not support custom content types like 'file' within messages.
// For this specific use case, using a direct HTTP client is the correct approach.

public class VoidonExample {
    public static void main(String[] args) {
        System.out.println("This library does not support the custom 'file' content type.");
        System.out.println("Please use the Client HTTP example for file uploads.");
    }
}
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;
import com.google.gson.Gson; // Dep: com.google.code.gson:gson
import com.google.gson.JsonObject;

public class VoidonHttpExample {
    public static void main(String[] args) throws IOException, InterruptedException {
        String apiKey = "your-voidon-api-key";
        String url = "https://api.voidon.astramind.ai/v1/chat/completions";

        // Read the PDF file and encode it in Base64
        byte[] pdfBytes = Files.readAllBytes(Paths.get("resume.pdf"));
        String pdfData = Base64.getEncoder().encodeToString(pdfBytes);

        // Using a library like Gson to build the JSON is safer
        Gson gson = new Gson();
        JsonObject filePayload = new JsonObject();
        filePayload.addProperty("url", "data:application/pdf;base64," + pdfData);

        JsonObject textPart = new JsonObject();
        textPart.addProperty("type", "text");
        textPart.addProperty("text", "Summarize this resume:");

        JsonObject filePart = new JsonObject();
        filePart.addProperty("type", "file");
        filePart.add("file", filePayload);

        JsonObject message = new JsonObject();
        message.addProperty("role", "user");
        message.add("content", gson.toJsonTree(new JsonObject[]{textPart, filePart}));

        JsonObject payload = new JsonObject();
        payload.addProperty("model", "auto");
        payload.add("messages", gson.toJsonTree(new JsonObject[]{message}));

        String jsonPayload = gson.toJson(payload);

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
                .build();

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

        JsonObject jsonResponse = gson.fromJson(response.body(), JsonObject.class);
        String content = jsonResponse.getAsJsonArray("choices")
                                     .get(0).getAsJsonObject()
                                     .getAsJsonObject("message")
                                     .get("content").getAsString();
        System.out.println(content);
    }
}
Ruby
require 'openai'
require 'base64'

# Note: The 'openai-ruby' gem expects specific content types like 'text' or
# 'image_url'. Passing a custom 'file' type might not be officially supported
# and depends on the flexibility of the library's parameter handling.
# The HTTP client method is generally more reliable for custom API features.

# Read the PDF file and encode it in Base64
pdf_data = Base64.strict_encode64(File.read('resume.pdf'))

client = OpenAI::Client.new(
  access_token: 'your-voidon-api-key',
  uri_base: 'https://api.voidon.astramind.ai/'
)

response = client.chat(
  parameters: {
    model: 'auto',
    messages: [{
      role: 'user',
      content: [
        { type: 'text', text: 'Summarize this resume:' },
        { 
          type: 'file', 
          file: { url: "data:application/pdf;base64,#{pdf_data}" }
        }
      ]
    }]
  }
)

puts response.dig('choices', 0, 'message', 'content')
Ruby
require 'uri'
require 'net/http'
require 'json'
require 'base64'

api_key = 'your-voidon-api-key'
uri = URI('https://api.voidon.astramind.ai/v1/chat/completions')

# Read the PDF file and encode it in Base64
pdf_data = Base64.strict_encode64(File.read('resume.pdf'))

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

request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request.body = JSON.dump({
  "model" => "auto",
  "messages" => [{
    "role" => "user",
    "content" => [
      { "type" => "text", "text" => "Summarize this resume:" },
      { 
        "type" => "file", 
        "file" => { "url" => "data:application/pdf;base64,#{pdf_data}" }
      }
    ]
  }]
})

response = http.request(request)

response_data = JSON.parse(response.read_body)
puts response_data.dig('choices', 0, 'message', 'content')

Streaming Responses

Get real-time responses as they're generated:

Bash
curl -N -X POST https://api.voidon.astramind.ai/v1/chat/completions \
  -H "Authorization: Bearer your-voidon-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [
      {"role": "user", "content": "Write a short story"}
    ],
    "stream": true
  }'
Python
import openai

client = openai.OpenAI(
    api_key="your-voidon-api-key",
    base_url="https://api.voidon.astramind.ai/v1"
)

stream = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Write a short story"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content is not None:
        print(chunk.choices[0].delta.content, end="")
Python
import requests
import json

API_KEY = "your-voidon-api-key"
API_URL = "https://api.voidon.astramind.ai/v1/chat/completions"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

payload = {
    "model": "auto",
    "messages": [{"role": "user", "content": "Write a short story"}],
    "stream": True
}

with requests.post(API_URL, headers=headers, json=payload, stream=True) as response:
    if response.status_code == 200:
        for line in response.iter_lines():
            if line:
                line_str = line.decode('utf-8')
                if line_str.startswith('data: '):
                    json_str = line_str[6:]
                    if json_str.strip() == '[DONE]':
                        break
                    try:
                        chunk = json.loads(json_str)
                        if chunk['choices'][0]['delta']['content']:
                            print(chunk['choices'][0]['delta']['content'], end="")
                    except json.JSONDecodeError:
                        continue
    else:
        print(f"Error: {response.status_code} - {response.text}")
JavaScript
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const stream = await openai.chat.completions.create({
        model: 'auto',
        messages: [{ role: 'user', content: 'Write a short story' }],
        stream: true,
    });

    for await (const chunk of stream) {
        if (chunk.choices[0]?.delta?.content) {
            process.stdout.write(chunk.choices[0].delta.content);
        }
    }
}

main();
JavaScript
async function main() {
    const apiKey = 'your-voidon-api-key';
    const apiUrl = 'https://api.voidon.astramind.ai/v1/chat/completions';

    const payload = {
        model: 'auto',
        messages: [{ role: 'user', content: 'Write a short story' }],
        stream: true,
    };

    const response = await fetch(apiUrl, {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${apiKey}`,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(payload)
    });

    const reader = response.body.getReader();
    const decoder = new TextDecoder();

    while (true) {
        const { done, value } = await reader.read();
        if (done) break;

        const sseLines = decoder.decode(value).split('\n');
        for (const line of sseLines) {
            if (line.startsWith('data: ')) {
                const jsonStr = line.substring(6);
                if (jsonStr.trim() === '[DONE]') break;
                try {
                    const chunk = JSON.parse(jsonStr);
                    if (chunk.choices[0]?.delta?.content) {
                        process.stdout.write(chunk.choices[0].delta.content);
                    }
                } catch (e) {}
            }
        }
    }
}

main();
TypeScript
import OpenAI from 'openai';

const openai = new OpenAI({
    apiKey: 'your-voidon-api-key',
    baseURL: 'https://api.voidon.astramind.ai/v1'
});

async function main() {
    const stream = await openai.chat.completions.create({
        model: 'auto',
        messages: [{ role: 'user', content: 'Write a short story' }],
        stream: true,
    });

    for await (const chunk of stream) {
        if (chunk.choices[0]?.delta?.content) {
            process.stdout.write(chunk.choices[0].delta.content);
        }
    }
}

main();
TypeScript
async function main() {
    const apiKey: string = 'your-voidon-api-key';
    const apiUrl: string = 'https://api.voidon.astramind.ai/v1/chat/completions';

    const payload = {
        model: 'auto',
        messages: [{ role: 'user', content: 'Write a short story' }],
        stream: true,
    };

    const response = await fetch(apiUrl, {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${apiKey}`,
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(payload)
    });

    if (!response.body) {
        throw new Error("Response body is null");
    }

    const reader = response.body.getReader();
    const decoder = new TextDecoder();

    while (true) {
        const { done, value } = await reader.read();
        if (done) break;

        const sseLines = decoder.decode(value).split('\n');
        for (const line of sseLines) {
            if (line.startsWith('data: ')) {
                const jsonStr = line.substring(6);
                if (jsonStr.trim() === '[DONE]') return;
                try {
                    const chunk = JSON.parse(jsonStr);
                    const content = chunk.choices[0]?.delta?.content;
                    if (content) {
                        process.stdout.write(content);
                    }
                } catch (e) {}
            }
        }
    }
}

main();
PHP
<?php
require_once __DIR__ . '/vendor/autoload.php';

$client = OpenAI::factory()
    ->withApiKey('your-voidon-api-key')
    ->withBaseUri('api.voidon.astramind.ai/v1') 
    ->make();

$stream = $client->chat()->createStreamed([
    'model' => 'auto',
    'messages' => [
        ['role' => 'user', 'content' => 'Write a short story'],
    ],
]);

foreach($stream as $response){
    $content = $response->choices[0]->delta->content;
    if ($content !== null) {
        echo $content;
    }
}
PHP
<?php

$apiKey = 'your-voidon-api-key';
$url = 'https://api.voidon.astramind.ai/v1/chat/completions';

$payload = json_encode([
    'model' => 'auto',
    'messages' => [['role' => 'user', 'content' => 'Write a short story']],
    'stream' => true
]);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: application/json',
    'Authorization: Bearer ' . $apiKey
]);
curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($curl, $data) {
    $lines = explode("\n", $data);
    foreach ($lines as $line) {
        if (strpos($line, 'data: ') === 0) {
            $jsonStr = substr($line, 6);
            if (trim($jsonStr) === '[DONE]') {
                break;
            }
            $chunk = json_decode($jsonStr, true);
            if (isset($chunk['choices'][0]['delta']['content'])) {
                echo $chunk['choices'][0]['delta']['content'];
                flush(); // Flush the output buffer
            }
        }
    }
    return strlen($data);
});

curl_exec($ch);
curl_close($ch);
Go
package main

import (
    "context"
    "errors"
    "fmt"
    "github.com/sashabaranov/go-openai"
    "io"
)

func main() {
    config := openai.DefaultConfig("your-voidon-api-key")
    config.BaseURL = "https://api.voidon.astramind.ai/v1"
    client := openai.NewClientWithConfig(config)

    request := openai.ChatCompletionRequest{
        Model: "auto",
        Messages: []openai.ChatCompletionMessage{
            {Role: openai.ChatMessageRoleUser, Content: "Write a short story"},
        },
        Stream: true,
    }
    stream, err := client.CreateChatCompletionStream(context.Background(), request)
    if err != nil {
        fmt.Printf("Error creating stream: %v\n", err)
        return
    }
    defer stream.Close()

    for {
        response, err := stream.Recv()
        if errors.Is(err, io.EOF) {
            break
        }
        if err != nil {
            fmt.Printf("\nStream error: %v\n", err)
            return
        }
        if len(response.Choices) > 0 {
            fmt.Printf(response.Choices[0].Delta.Content)
        }
    }
}
Go
package main

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

func main() {
    apiKey := "your-voidon-api-key"
    url := "https://api.voidon.astramind.ai/v1/chat/completions"

    requestBody, _ := json.Marshal(map[string]interface{}{
        "model":    "auto",
        "messages": []map[string]string{{"role": "user", "content": "Write a short story"}},
        "stream":   true,
    })

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(requestBody))
    req.Header.Set("Authorization", "Bearer "+apiKey)
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    reader := bufio.NewReader(resp.Body)
    for {
        line, err := reader.ReadString('\n')
        if err != nil {
            if err != io.EOF {
                fmt.Println("Error reading stream:", err)
            }
            break
        }
        if strings.HasPrefix(line, "data: ") {
            dataStr := strings.TrimPrefix(line, "data: ")
            if strings.TrimSpace(dataStr) == "[DONE]" {
                break
            }
            var chunk struct {
                Choices []struct {
                    Delta struct {
                        Content string `json:"content"`
                    } `json:"delta"`
                } `json:"choices"`
            }
            if err := json.Unmarshal([]byte(dataStr), &chunk); err == nil {
                if len(chunk.Choices) > 0 {
                    fmt.Print(chunk.Choices[0].Delta.Content)
                }
            }
        }
    }
}
Java
// Dep: com.theokanning.openai-service
import com.theokanning.openai.completion.chat.ChatCompletionRequest;
import com.theokanning.openai.completion.chat.ChatMessage;
import com.theokanning.openai.service.OpenAiService;
import java.util.List;

public class VoidonStreamExample {
    public static void main(String[] args) {
        // Note: The base_url needs custom Retrofit configuration
        // as shown in previous examples to point to the custom API.
        OpenAiService service = new OpenAiService("your-voidon-api-key");

        ChatCompletionRequest request = ChatCompletionRequest.builder()
            .model("auto")
            .messages(List.of(new ChatMessage("user", "Write a short story")))
            .stream(true)
            .build();

        service.streamChatCompletion(request)
            .blockingForEach(chunk -> {
                if (chunk.getChoices().get(0).getMessage().getContent() != null) {
                    System.out.print(chunk.getChoices().get(0).getMessage().getContent());
                }
            });
    }
}
Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import com.google.gson.Gson; // Dep: com.google.code.gson:gson
import com.google.gson.JsonObject;

public class VoidonHttpStreamExample {
    public static void main(String[] args) {
        String apiKey = "your-voidon-api-key";
        String url = "https://api.voidon.astramind.ai/v1/chat/completions";
        Gson gson = new Gson();

        String jsonPayload = """
        {
            "model": "auto",
            "messages": [{"role": "user", "content": "Write a short story"}],
            "stream": true
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create(url))
                .header("Authorization", "Bearer " + apiKey)
                .header("Content-Type", "application/json")
                .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
                .build();

        client.sendAsync(request, HttpResponse.BodyHandlers.ofLines())
            .thenApply(HttpResponse::body)
            .thenAccept(lines -> lines.forEach(line -> {
                if (line.startsWith("data: ")) {
                    String jsonStr = line.substring(6);
                    if (jsonStr.trim().equals("[DONE]")) {
                        return;
                    }
                    try {
                        JsonObject chunk = gson.fromJson(jsonStr, JsonObject.class);
                        String content = chunk.getAsJsonArray("choices")
                                              .get(0).getAsJsonObject()
                                              .getAsJsonObject("delta")
                                              .get("content").getAsString();
                        System.out.print(content);
                    } catch (Exception e) {}
                }
            })).join();
    }
}
Ruby
require 'openai'

client = OpenAI::Client.new(
  access_token: 'your-voidon-api-key',
  uri_base: 'https://api.voidon.astramind.ai/'
)

client.chat(
  parameters: {
    model: 'auto',
    messages: [{ role: 'user', content: 'Write a short story' }],
    stream: proc do |chunk, _bytesize|
      content = chunk.dig('choices', 0, 'delta', 'content')
      print content if content
    end
  }
)
Ruby
require 'uri'
require 'net/http'
require 'json'

api_key = 'your-voidon-api-key'
uri = URI('https://api.voidon.astramind.ai/v1/chat/completions')

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

request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{api_key}"
request['Content-Type'] = 'application/json'
request.body = JSON.dump({
  "model" => "auto",
  "messages" => [{ "role" => "user", "content" => "Write a short story" }],
  "stream" => true
})

http.request(request) do |response|
  response.read_body do |chunk|
    chunk.split("\n").each do |line|
      next unless line.start_with?('data: ')
      json_str = line.sub(/^data: /, '')
      next if json_str.strip == '[DONE]'
      begin
        data = JSON.parse(json_str)
        content = data.dig('choices', 0, 'delta', 'content')
        print content if content
      rescue JSON::ParserError
        next
      end
    end
  end
end

Next Steps

Now that you've made your first request, explore more:

  • Configuration


    Learn about environment setup and advanced configuration

    Configuration Guide

  • API Reference


    Explore all available endpoints and parameters

    Full API Docs

  • More Examples


    See real-world usage patterns and integration examples

    Python JS

  • Dashboard


    Monitor and analyze usage patterns

    Analytics hub

Getting Help