Quickstart
From zero to your first answer in minutes — over plain HTTP. No SDK to install: works from any language with curl, Python, JavaScript, Go and beyond.
1 · Get a project key
Every request authenticates with a project key in the Authorization header. Get one by signing in at the console: Google/GitHub gives you a project key + $2 free credit (email sign-in starts at $0). Copy the key and export it once. When the wallet runs out you get a 402 INSUFFICIENT_CREDIT — POST /v1/account/topup and open the returned checkout_url to add funds:
# Get a project key: sign in with Google/GitHub at the console for your
# project key + $2 free credit (email sign-in starts at $0). Copy the key,
# then export it once:
export INFRAI_API_KEY="ifr_..."
# When the wallet runs out you get 402 INSUFFICIENT_CREDIT — top up and open
# the returned checkout_url to add funds:
curl -X POST https://api.infrai.cc/v1/account/topup \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"amount": 20, "currency": "USD", "payment_method": "stripe"}'2 · AI inference — point the OpenAI SDK at infrai
AI inference is OpenAI-API-compatible: you already know the API. Just change the base URL to https://api.infrai.cc/v1 and use chat/completions, embeddings, images/generations, audio/speech, audio/transcriptions, moderations and models exactly as you know them. No new SDK, no new knowledge.
from openai import OpenAI
client = OpenAI(base_url="https://api.infrai.cc/v1", api_key=INFRAI_API_KEY)
resp = client.chat.completions.create(
model="auto", # infrai picks the best/cheapest live vendor; or pin "gpt-4o-mini"
messages=[{"role": "user", "content": "Summarize the latest news"}],
)
print(resp.choices[0].message.content)
print(resp.infrai["cost_usd"], resp.infrai["vendor"]) # infrai cost/vendor extensionSmart routing rides the model field: model="auto" lets infrai pick the best/cheapest live vendor (pass task/prefer via extra_body), or pin a real model like "gpt-4o-mini" / "deepseek-chat". Cost and vendor come back in an extra top-level infrai object plus X-Infrai-* headers — an OpenAI client ignores the extra field. (The old custom /v1/ai/chat shapes are retired.)
3 · Any other capability
Everything non-AI is a plain HTTP call to https://api.infrai.cc/v1/... — POST JSON with a Bearer key. Send an email, schedule a job, store a file — same key, same envelope, just a different path. For example, send an email:
curl -X POST https://api.infrai.cc/v1/email/send \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to": "sample"}'# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.post(
"https://api.infrai.cc/v1/email/send",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'to': 'sample'},
)
resp.raise_for_status()
print(resp.json())// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/email/send",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"to": "sample"}),
},
);
console.log(await resp.json());// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/email/send",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"to": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);// Zero-install REST call — no SDK required (short-term the API is REST-only).
package main
import (
"bytes"
"fmt"
"net/http"
"os"
)
func main() {
body := []byte(`{"to": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/email/send", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
fmt.Println(resp.Status)
}// Zero-install REST call — no SDK required (short-term the API is REST-only).
import java.net.URI;
import java.net.http.*;
HttpRequest req = HttpRequest.newBuilder()
.uri(URI.create("https://api.infrai.cc/v1/email/send"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"to\": \"sample\"}"))
.build();
HttpResponse<String> resp = HttpClient.newHttpClient()
.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(resp.body());// Zero-install REST call — no SDK required (short-term the API is REST-only).
using System;
using System.Net.Http;
var client = new HttpClient();
var req = new HttpRequestMessage(new HttpMethod("POST"), "https://api.infrai.cc/v1/email/send");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"to\": \"sample\"}", System.Text.Encoding.UTF8, "application/json");
var resp = await client.SendAsync(req);
Console.WriteLine(await resp.Content.ReadAsStringAsync());<?php
// Zero-install REST call — no SDK required (short-term the API is REST-only).
$ch = curl_init("https://api.infrai.cc/v1/email/send");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
"Content-Type: application/json",
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"to\": \"sample\"}");
$response = curl_exec($ch);
curl_close($ch);
echo $response;# Zero-install REST call — no SDK required (short-term the API is REST-only).
require "net/http"
require "uri"
uri = URI("https://api.infrai.cc/v1/email/send")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
req["Content-Type"] = "application/json"
req.body = '{"to": "sample"}'
res = http.request(req)
puts res.body// Zero-install REST call — no SDK required (short-term the API is REST-only). (uses the reqwest + tokio crates)
use std::env;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let resp = reqwest::Client::new()
.post("https://api.infrai.cc/v1/email/send")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"to": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}Response
{
"ok": true,
"data": { /* capability-specific result */ },
"error": null,
"metadata": {
"cost_usd": 0.00012,
"latency_ms": 412,
"vendor": "deepseek",
"cache_hit": false,
"request_id": "01HXY..." // UUID v7
}
}Every call returns the same envelope: `data` is the capability result, `error` is null on success, and `metadata` carries cost, vendor, latency and the request id. See Conventions for the full spec.
Any language
It is just HTTP, so any language with an HTTP client works — Go, Rust, Java, C#/.NET, Ruby, PHP and more. Every response returns the same { ok, data, error, metadata } envelope with cost, latency and vendor metadata.