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
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
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
// Dep: com.theokanning.openai-service// Note: configuration of base_url with this lib requires// the creation of a custom Retrofit instance importcom.theokanning.openai.completion.chat.ChatCompletionRequest;importcom.theokanning.openai.completion.chat.ChatMessage;importcom.theokanning.openai.service.OpenAiService;importjava.util.List;importokhttp3.OkHttpClient;importretrofit2.Retrofit;importretrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;importretrofit2.converter.jackson.JacksonConverterFactory;importjava.time.Duration;publicclassVoidonExample{publicstaticvoidmain(String[]args){StringapiKey="your-voidon-api-key";StringbaseUrl="https://api.voidon.astramind.ai/";// La v1 è nel path dell'endpoint// Configurazione client avanzata per impostare il Base URLOkHttpClientclient=OpenAiService.defaultClient(apiKey,Duration.ofSeconds(60)).newBuilder().build();Retrofitretrofit=newRetrofit.Builder().baseUrl(baseUrl).client(client).addConverterFactory(JacksonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build();OpenAiServiceservice=newOpenAiService(retrofit.create(com.theokanning.openai.service.OpenAiApi.class));ChatCompletionRequestrequest=ChatCompletionRequest.builder().model("auto").messages(List.of(newChatMessage("user","Hello!"))).build();varresponse=service.createChatCompletion(request);System.out.println(response.getChoices().get(0).getMessage().getContent());}}
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!'}]})putsresponse.dig('choices',0,'message','content')
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.
// Dep: com.theokanning.openai-service// Note: configuration of base_url with this lib requires// the creation of a custom Retrofit instance importcom.theokanning.openai.completion.chat.ChatCompletionRequest;importcom.theokanning.openai.completion.chat.ChatMessage;importcom.theokanning.openai.service.OpenAiService;importjava.util.List;importokhttp3.OkHttpClient;importretrofit2.Retrofit;importretrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;importretrofit2.converter.jackson.JacksonConverterFactory;importjava.time.Duration;publicclassVoidonExample{publicstaticvoidmain(String[]args){StringapiKey="your-voidon-api-key";StringbaseUrl="https://api.voidon.astramind.ai/";// La v1 è nel path dell'endpoint// Configurazione client avanzata per impostare il Base URLOkHttpClientclient=OpenAiService.defaultClient(apiKey,Duration.ofSeconds(60)).newBuilder().build();Retrofitretrofit=newRetrofit.Builder().baseUrl(baseUrl).client(client).addConverterFactory(JacksonConverterFactory.create()).addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build();OpenAiServiceservice=newOpenAiService(retrofit.create(com.theokanning.openai.service.OpenAiApi.class));ChatCompletionRequestrequest=ChatCompletionRequest.builder().model("[chosen-model-group]/auto").messages(List.of(newChatMessage("user","Hello!"))).build();varresponse=service.createChatCompletion(request);System.out.println(response.getChoices().get(0).getMessage().getContent());}}
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!'}]})putsresponse.dig('choices',0,'message','content')
curl-XPOSThttps://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 }'
importopenaiclient=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)
importrequestsimportjsonAPI_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))ifresponse.status_code==200:print(response.json()['choices'][0]['message']['content'])else:print(f"Error: {response.status_code} - {response.text}")
importOpenAIfrom'openai';constopenai=newOpenAI({apiKey:'your-voidon-api-key',baseURL:'https://api.voidon.astramind.ai/v1'});asyncfunctionmain(){constresponse=awaitopenai.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 parameterenable_anonymization:true,// 🔒 Automatic PII removal});console.log(response.choices[0].message.content);}main();
constapiKey='your-voidon-api-key';constapiUrl='https://api.voidon.astramind.ai/v1/chat/completions';constpayload={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));
importOpenAIfrom'openai';constopenai=newOpenAI({apiKey:'your-voidon-api-key',baseURL:'https://api.voidon.astramind.ai/v1'});asyncfunctionmain(){constresponse=awaitopenai.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 parameterenable_anonymization:true,// 🔒 Automatic PII removal});console.log(response.choices[0]?.message?.content);}main();
constapiKey:string='your-voidon-api-key';constapiUrl:string='https://api.voidon.astramind.ai/v1/chat/completions';interfaceMessage{role:'user'|'assistant'|'system';content:string;}interfacePayload{model:string;messages:Message[];enable_anonymization?:boolean;// 🔒 Automatic PII removal}constpayload: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,};asyncfunctionmain(){try{constresponse=awaitfetch(apiUrl,{method:'POST',headers:{'Authorization':`Bearer ${apiKey}`,'Content-Type':'application/json'},body:JSON.stringify(payload)});if(!response.ok){thrownewError(`HTTP error! status: ${response.status}`);}constdata=awaitresponse.json();console.log(data.choices[0]?.message?.content);}catch(error){console.error('Error:',error);}}main();
<?phprequire_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$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'];
packagemainimport("context""fmt""github.com/sashabaranov/go-openai")funcmain(){// 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.",},},},)iferr!=nil{fmt.Printf("Error: %v\n",err)return}fmt.Println(resp.Choices[0].Message.Content)}
packagemainimport("bytes""encoding/json""fmt""io/ioutil""net/http")funcmain(){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)iferr!=nil{panic(err)}deferresp.Body.Close()body,_:=ioutil.ReadAll(resp.Body)varresultmap[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)}
// Dep: com.theokanning.openai-serviceimportcom.theokanning.openai.completion.chat.ChatCompletionRequest;importcom.theokanning.openai.completion.chat.ChatMessage;importcom.theokanning.openai.service.OpenAiService;importjava.util.List;publicclassVoidonExample{publicstaticvoidmain(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.OpenAiServiceservice=newOpenAiService("your-voidon-api-key");ChatCompletionRequestrequest=ChatCompletionRequest.builder().model("auto").messages(List.of(newChatMessage("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());}}
importjava.net.URI;importjava.net.http.HttpClient;importjava.net.http.HttpRequest;importjava.net.http.HttpResponse;importjava.io.IOException;importcom.google.gson.Gson;// Example using Gson for parsingimportcom.google.gson.JsonObject;publicclassVoidonHttpExample{publicstaticvoidmain(String[]args)throwsIOException,InterruptedException{StringapiKey="your-voidon-api-key";Stringurl="https://api.voidon.astramind.ai/v1/chat/completions";StringjsonPayload=""" { "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 } """;HttpClientclient=HttpClient.newHttpClient();HttpRequestrequest=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 parsingJsonObjectjsonResponse=newGson().fromJson(response.body(),JsonObject.class);Stringcontent=jsonResponse.getAsJsonArray("choices").get(0).getAsJsonObject().getAsJsonObject("message").get("content").getAsString();System.out.println(content);}}
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})putsresponse.dig('choices',0,'message','content')
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=truerequest=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)putsresponse_data.dig('choices',0,'message','content')
# First, encode the PDF in Base64 and store it in a variablepdf_data=$(base64-w0resume.pdf)# Then, make the API call with the Base64 data embedded in the JSONcurl-XPOSThttps://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"'" } } ] }] }'
importopenaiimportbase64# Read the PDF file and encode it in Base64withopen("resume.pdf","rb")asfile: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)
importrequestsimportjsonimportbase64API_KEY="your-voidon-api-key"API_URL="https://api.voidon.astramind.ai/v1/chat/completions"# Read the PDF file and encode it in Base64withopen("resume.pdf","rb")asfile: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))ifresponse.status_code==200:print(response.json()['choices'][0]['message']['content'])else:print(f"Error: {response.status_code} - {response.text}")
importOpenAIfrom'openai';importfsfrom'fs';// Read the PDF file and encode it in Base64constpdfData=fs.readFileSync('resume.pdf').toString('base64');constopenai=newOpenAI({apiKey:'your-voidon-api-key',baseURL:'https://api.voidon.astramind.ai/v1'});asyncfunctionmain(){constresponse=awaitopenai.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();
importfsfrom'fs';constapiKey='your-voidon-api-key';constapiUrl='https://api.voidon.astramind.ai/v1/chat/completions';// Read the PDF file and encode it in Base64constpdfData=fs.readFileSync('resume.pdf').toString('base64');constpayload={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));
importOpenAIfrom'openai';import*asfsfrom'fs';// Read the PDF file and encode it in Base64constpdfData=fs.readFileSync('resume.pdf').toString('base64');constopenai=newOpenAI({apiKey:'your-voidon-api-key',baseURL:'https://api.voidon.astramind.ai/v1'});// Define a more flexible type for the message contenttypeMessageContent=(OpenAI.Chat.Completions.ChatCompletionContentPart&{type:'file';file?:{url:string}})[];asyncfunctionmain(){constresponse=awaitopenai.chat.completions.create({model:'auto',messages:[{role:'user',content:[{type:'text',text:'Summarize this resume:'},{type:'file',file:{url:`data:application/pdf;base64,${pdfData}`}}]asunknownasMessageContent,// Cast to custom type}],});console.log(response.choices[0]?.message?.content);}main();
import*asfsfrom'fs';constapiKey:string='your-voidon-api-key';constapiUrl:string='https://api.voidon.astramind.ai/v1/chat/completions';// Read the PDF file and encode it in Base64constpdfData:string=fs.readFileSync('resume.pdf').toString('base64');interfaceMessageContentPart{type:'text'|'file';text?:string;file?:{url:string;};}interfaceMessage{role:'user'|'assistant'|'system';content:MessageContentPart[];}constpayload:{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}`}}]}],};asyncfunctionmain(){try{constresponse=awaitfetch(apiUrl,{method:'POST',headers:{'Authorization':`Bearer ${apiKey}`,'Content-Type':'application/json'},body:JSON.stringify(payload)});if(!response.ok){thrownewError(`HTTP error! status: ${response.status}`);}constdata=awaitresponse.json();console.log(data.choices[0]?.message?.content);}catch(error){console.error('Error:',error);}}main();
<?phprequire_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$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'];
packagemainimport("context""encoding/base64""fmt""io/ioutil""github.com/sashabaranov/go-openai")funcmain(){// 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 Base64pdfBytes,err:=ioutil.ReadFile("resume.pdf")iferr!=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),},},},},},},)iferr!=nil{fmt.Printf("Error: %v\n",err)return}fmt.Println(resp.Choices[0].Message.Content)}
packagemainimport("bytes""encoding/base64""encoding/json""fmt""io/ioutil""net/http")funcmain(){apiKey:="your-voidon-api-key"url:="https://api.voidon.astramind.ai/v1/chat/completions"// Read the PDF file and encode it in Base64pdfBytes,err:=ioutil.ReadFile("resume.pdf")iferr!=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)iferr!=nil{panic(err)}deferresp.Body.Close()body,_:=ioutil.ReadAll(resp.Body)varresultmap[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)}
// 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.publicclassVoidonExample{publicstaticvoidmain(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.");}}
importjava.net.URI;importjava.net.http.HttpClient;importjava.net.http.HttpRequest;importjava.net.http.HttpResponse;importjava.io.IOException;importjava.nio.file.Files;importjava.nio.file.Paths;importjava.util.Base64;importcom.google.gson.Gson;// Dep: com.google.code.gson:gsonimportcom.google.gson.JsonObject;publicclassVoidonHttpExample{publicstaticvoidmain(String[]args)throwsIOException,InterruptedException{StringapiKey="your-voidon-api-key";Stringurl="https://api.voidon.astramind.ai/v1/chat/completions";// Read the PDF file and encode it in Base64byte[]pdfBytes=Files.readAllBytes(Paths.get("resume.pdf"));StringpdfData=Base64.getEncoder().encodeToString(pdfBytes);// Using a library like Gson to build the JSON is saferGsongson=newGson();JsonObjectfilePayload=newJsonObject();filePayload.addProperty("url","data:application/pdf;base64,"+pdfData);JsonObjecttextPart=newJsonObject();textPart.addProperty("type","text");textPart.addProperty("text","Summarize this resume:");JsonObjectfilePart=newJsonObject();filePart.addProperty("type","file");filePart.add("file",filePayload);JsonObjectmessage=newJsonObject();message.addProperty("role","user");message.add("content",gson.toJsonTree(newJsonObject[]{textPart,filePart}));JsonObjectpayload=newJsonObject();payload.addProperty("model","auto");payload.add("messages",gson.toJsonTree(newJsonObject[]{message}));StringjsonPayload=gson.toJson(payload);HttpClientclient=HttpClient.newHttpClient();HttpRequestrequest=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());JsonObjectjsonResponse=gson.fromJson(response.body(),JsonObject.class);Stringcontent=jsonResponse.getAsJsonArray("choices").get(0).getAsJsonObject().getAsJsonObject("message").get("content").getAsString();System.out.println(content);}}
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 Base64pdf_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}"}}]}]})putsresponse.dig('choices',0,'message','content')
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 Base64pdf_data=Base64.strict_encode64(File.read('resume.pdf'))http=Net::HTTP.new(uri.host,uri.port)http.use_ssl=truerequest=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)putsresponse_data.dig('choices',0,'message','content')
importopenaiclient=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)forchunkinstream:ifchunk.choices[0].delta.contentisnotNone:print(chunk.choices[0].delta.content,end="")
importrequestsimportjsonAPI_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}withrequests.post(API_URL,headers=headers,json=payload,stream=True)asresponse:ifresponse.status_code==200:forlineinresponse.iter_lines():ifline:line_str=line.decode('utf-8')ifline_str.startswith('data: '):json_str=line_str[6:]ifjson_str.strip()=='[DONE]':breaktry:chunk=json.loads(json_str)ifchunk['choices'][0]['delta']['content']:print(chunk['choices'][0]['delta']['content'],end="")exceptjson.JSONDecodeError:continueelse:print(f"Error: {response.status_code} - {response.text}")
importOpenAIfrom'openai';constopenai=newOpenAI({apiKey:'your-voidon-api-key',baseURL:'https://api.voidon.astramind.ai/v1'});asyncfunctionmain(){conststream=awaitopenai.chat.completions.create({model:'auto',messages:[{role:'user',content:'Write a short story'}],stream:true,});forawait(constchunkofstream){if(chunk.choices[0]?.delta?.content){process.stdout.write(chunk.choices[0].delta.content);}}}main();
asyncfunctionmain(){constapiKey='your-voidon-api-key';constapiUrl='https://api.voidon.astramind.ai/v1/chat/completions';constpayload={model:'auto',messages:[{role:'user',content:'Write a short story'}],stream:true,};constresponse=awaitfetch(apiUrl,{method:'POST',headers:{'Authorization':`Bearer ${apiKey}`,'Content-Type':'application/json'},body:JSON.stringify(payload)});constreader=response.body.getReader();constdecoder=newTextDecoder();while(true){const{done,value}=awaitreader.read();if(done)break;constsseLines=decoder.decode(value).split('\n');for(constlineofsseLines){if(line.startsWith('data: ')){constjsonStr=line.substring(6);if(jsonStr.trim()==='[DONE]')break;try{constchunk=JSON.parse(jsonStr);if(chunk.choices[0]?.delta?.content){process.stdout.write(chunk.choices[0].delta.content);}}catch(e){}}}}}main();
importOpenAIfrom'openai';constopenai=newOpenAI({apiKey:'your-voidon-api-key',baseURL:'https://api.voidon.astramind.ai/v1'});asyncfunctionmain(){conststream=awaitopenai.chat.completions.create({model:'auto',messages:[{role:'user',content:'Write a short story'}],stream:true,});forawait(constchunkofstream){if(chunk.choices[0]?.delta?.content){process.stdout.write(chunk.choices[0].delta.content);}}}main();
asyncfunctionmain(){constapiKey:string='your-voidon-api-key';constapiUrl:string='https://api.voidon.astramind.ai/v1/chat/completions';constpayload={model:'auto',messages:[{role:'user',content:'Write a short story'}],stream:true,};constresponse=awaitfetch(apiUrl,{method:'POST',headers:{'Authorization':`Bearer ${apiKey}`,'Content-Type':'application/json'},body:JSON.stringify(payload)});if(!response.body){thrownewError("Response body is null");}constreader=response.body.getReader();constdecoder=newTextDecoder();while(true){const{done,value}=awaitreader.read();if(done)break;constsseLines=decoder.decode(value).split('\n');for(constlineofsseLines){if(line.startsWith('data: ')){constjsonStr=line.substring(6);if(jsonStr.trim()==='[DONE]')return;try{constchunk=JSON.parse(jsonStr);constcontent=chunk.choices[0]?.delta?.content;if(content){process.stdout.write(content);}}catch(e){}}}}}main();
<?phprequire_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($streamas$response){$content=$response->choices[0]->delta->content;if($content!==null){echo$content;}}
<?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($linesas$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}}}returnstrlen($data);});curl_exec($ch);curl_close($ch);
packagemainimport("context""errors""fmt""github.com/sashabaranov/go-openai""io")funcmain(){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)iferr!=nil{fmt.Printf("Error creating stream: %v\n",err)return}deferstream.Close()for{response,err:=stream.Recv()iferrors.Is(err,io.EOF){break}iferr!=nil{fmt.Printf("\nStream error: %v\n",err)return}iflen(response.Choices)>0{fmt.Printf(response.Choices[0].Delta.Content)}}}
packagemainimport("bufio""bytes""encoding/json""fmt""io""net/http""strings")funcmain(){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)iferr!=nil{panic(err)}deferresp.Body.Close()reader:=bufio.NewReader(resp.Body)for{line,err:=reader.ReadString('\n')iferr!=nil{iferr!=io.EOF{fmt.Println("Error reading stream:",err)}break}ifstrings.HasPrefix(line,"data: "){dataStr:=strings.TrimPrefix(line,"data: ")ifstrings.TrimSpace(dataStr)=="[DONE]"{break}varchunkstruct{Choices[]struct{Deltastruct{Contentstring`json:"content"`}`json:"delta"`}`json:"choices"`}iferr:=json.Unmarshal([]byte(dataStr),&chunk);err==nil{iflen(chunk.Choices)>0{fmt.Print(chunk.Choices[0].Delta.Content)}}}}}
// Dep: com.theokanning.openai-serviceimportcom.theokanning.openai.completion.chat.ChatCompletionRequest;importcom.theokanning.openai.completion.chat.ChatMessage;importcom.theokanning.openai.service.OpenAiService;importjava.util.List;publicclassVoidonStreamExample{publicstaticvoidmain(String[]args){// Note: The base_url needs custom Retrofit configuration// as shown in previous examples to point to the custom API.OpenAiServiceservice=newOpenAiService("your-voidon-api-key");ChatCompletionRequestrequest=ChatCompletionRequest.builder().model("auto").messages(List.of(newChatMessage("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());}});}}
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:procdo|chunk,_bytesize|content=chunk.dig('choices',0,'delta','content')printcontentifcontentend})
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=truerequest=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_bodydo|chunk|chunk.split("\n").eachdo|line|nextunlessline.start_with?('data: ')json_str=line.sub(/^data: /,'')nextifjson_str.strip=='[DONE]'begindata=JSON.parse(json_str)content=data.dig('choices',0,'delta','content')printcontentifcontentrescueJSON::ParserErrornextendendendend