AI Runtime
Core LLM inference — chat, embeddings, vision, image generation, speech (TTS/ASR) — is OpenAI-compatible: call it with the official openai SDK pointed at the infrai base_url. The methods here are the infrai-native extensions: batch, cost/token tooling, rerank, image upscale, TTS voices and live voice sessions.
OpenAI-compatible endpoints
Core AI inference (chat, embeddings, image, TTS, ASR, moderation, models) is served on the standard OpenAI API surface — point the OpenAI SDK at infrai's base URL. Full examples → Looking for chat, embeddings, images or speech? Those are served on the OpenAI-compatible API — point the OpenAI SDK at infrai →
| Endpoint | infrai capability | Purpose |
|---|---|---|
POST /v1/chat/completions | ai.chat | Chat completions — text, vision and tool calls, with streaming. |
POST /v1/embeddings | ai.embed | Text embeddings for search and RAG. |
POST /v1/images/generations | ai.image | Image generation from a text prompt. |
POST /v1/audio/speech | ai.tts | Text-to-speech — synthesize spoken audio. |
POST /v1/audio/transcriptions | ai.asr | Speech-to-text — transcribe an audio file. |
POST /v1/moderations | ai.moderation | Classify whether content violates usage policy. |
GET /v1/models | ai.models.list | List every model a verified, routable vendor serves. |
GET /v1/models/{model} | ai.models.get | Retrieve one model's details (pricing, context, availability). |
1. Overview
https://api.infrai.cc/v1/aiAuthorization: Bearer $INFRAI_API_KEY# Call any /v1/ai capability over raw HTTP — no SDK to install.
# curl:
curl https://api.infrai.cc/v1/ai/... \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json"2. Methods (11)
2.1ai.batch.submit
Submit a batch of AI requests as a single asynchronous batch processing task, and the batch mode is transparently transmitted at the original cost.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
requests | BatchRequestItem[] | Required | An array of batch request entries, each containing capability and body.≥ 1 item |
batch_timeout | string | Optional | The maximum completion time for batch processing (such as 24h). Entries that are not completed after the timeout are processed as failures.default: "24h"e.g. 1h |
metadata | Record<string, unknown> | Optional | Custom key-value metadata attached to the batch task. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
BatchSubmitResult { batch_id, state, total_count, estimated_eta?, estimated_cost_usd? }| Name | Type | Description |
|---|---|---|
batch_id | string | Unique identifier for this batch jobpattern: ^batch_[A-Za-z0-9]{20,}$ |
state | "connecting" | "queued" | "in_progress" | "completed" | "failed" | "expired" | "cancelled" | Current lifecycle state of this resource |
total_count | integer | Total number of items across all pages≥ 1 |
estimated_eta | string | null | Estimated time remaining for batch completionformat: date-time |
estimated_cost_usd | number | null | Estimated total cost for the batch in USD≥ 0 |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/ai/batch/submit \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"requests": [{}]}'# 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/ai/batch/submit",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'requests': [{}]},
)
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/ai/batch/submit",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"requests": [{}]}),
},
);
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/ai/batch/submit",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"requests": [{}]}),
},
);
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(`{"requests": [{}]}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/ai/batch/submit", 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/ai/batch/submit"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"requests\": [{}]}"))
.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/ai/batch/submit");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"requests\": [{}]}", 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/ai/batch/submit");
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, "{\"requests\": [{}]}");
$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/ai/batch/submit")
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 = '{"requests": [{}]}'
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/ai/batch/submit")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"requests": [{}]}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.2ai.batch.status
Query the status, progress and completed/failed count of batch tasks.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
batch_id | string | Required | The ID of the target batch task. |
Returns
BatchStatus { batch_id, state, progress, total_count, completed_count, failed_count, created_at, total_cost_usd? }| Name | Type | Description |
|---|---|---|
batch_id | string | Unique identifier for this batch jobpattern: ^batch_[A-Za-z0-9]{20,}$ |
state | "connecting" | "queued" | "in_progress" | "partial" | "completed" | "failed" | "expired" | "cancelled" | Current lifecycle state of this resource |
progress | number | Progress of the async operation (0.0 to 1.0)0–1 |
total_count | integer | Total number of items across all pages≥ 0 |
completed_count | integer | Number of completed items in the batch≥ 0 |
failed_count | integer | Number of failed items in the batch≥ 0 |
created_at | string | ISO 8601 timestamp when this resource was createdformat: date-time |
estimated_completion_at | string | null | Estimated ISO 8601 timestamp when the batch will completeformat: date-time |
actual_completion_at | string | null | ISO 8601 timestamp when the batch actually completedformat: date-time |
total_cost_usd | number | null | Total cost of the batch in USD≥ 0 |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/ai/batch/status/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/ai/batch/status/ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
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/ai/batch/status/ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
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/ai/batch/status/ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
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 (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/ai/batch/status/ID", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
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/ai/batch/status/ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.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("GET"), "https://api.infrai.cc/v1/ai/batch/status/ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
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/ai/batch/status/ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$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/ai/batch/status/ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
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()
.get("https://api.infrai.cc/v1/ai/batch/status/ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.3ai.batch.results
Pull the results of the batch processing task one by one in pages.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
batch_id | string | Required | The ID of the target batch task. |
cursor | string | Optional | Paging cursor: Pass in the next_cursor returned from the previous page to get the next page. |
limit | number | Optional | The maximum number of items returned on a single page. |
Returns
BatchResultsPage { items, total_count, next_cursor?, download_url? }| Name | Type | Description |
|---|---|---|
items | object[] | Array of result items in this page |
items[].request_index | integer | Index in the original requests array.≥ 0 |
items[].ok | boolean | Whether the operation succeeded |
items[].result | any | Capability result (ChatResult / EmbeddingResult) when ok=true. |
items[].error | object | null | Error message if the operation failed |
items[].error.code | string | Stable identifier from registry.yaml. |
items[].error.http_status | integer | HTTP status code of the webhook delivery attempt400–599 |
items[].error.message | string | Human-readable hint. |
items[].error.docs_url | string | Documentation URL for this error codeformat: uri |
items[].error.code_detail | string | Sub-classification (e.g. wallet cap reason). |
items[].error.retryable | boolean | Whether the error is retryable |
items[].error.retry_after_ms | integer | Suggested retry delay in milliseconds≥ 0 |
items[].error.param | string | Which parameter failed validation, if applicable. |
items[].error.trace_id | string | Distributed tracing identifier |
items[].error.request_id | string | Server-assigned request identifier for tracing |
total_count | integer | Total number of items across all pages≥ 0 |
next_cursor | string | null | Pass back into results() to fetch the next page. null = end. |
download_url | string | null | Bulk download reference for large result sets (JSONL); null when results are inlined.format: uri |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/ai/batch/results/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/ai/batch/results/ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
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/ai/batch/results/ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
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/ai/batch/results/ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
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 (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/ai/batch/results/ID", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
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/ai/batch/results/ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.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("GET"), "https://api.infrai.cc/v1/ai/batch/results/ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
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/ai/batch/results/ID");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$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/ai/batch/results/ID")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
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()
.get("https://api.infrai.cc/v1/ai/batch/results/ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.4ai.batch.list
List all batch processing tasks of this account in pages.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
cursor | string | Optional | Paging cursor: Pass in the next_cursor returned from the previous page to get the next page. |
limit | number | Optional | The maximum number of items returned on a single page. |
Returns
BatchListResult { batches, total_count, next_cursor? }| Name | Type | Description |
|---|---|---|
batches | object[] | List of batch summary objects |
batches[].batch_id | string | Unique identifier for this batch jobpattern: ^batch_[A-Za-z0-9]{20,}$ |
batches[].state | "connecting" | "queued" | "in_progress" | "partial" | "completed" | "failed" | "expired" | "cancelled" | Current lifecycle state of this resource |
batches[].progress | number | Progress of the async operation (0.0 to 1.0)0–1 |
batches[].total_count | integer | Total number of items across all pages≥ 0 |
batches[].completed_count | integer | Number of completed items in the batch≥ 0 |
batches[].failed_count | integer | Number of failed items in the batch≥ 0 |
batches[].created_at | string | ISO 8601 timestamp when this resource was createdformat: date-time |
batches[].estimated_completion_at | string | null | Estimated ISO 8601 timestamp when the batch will completeformat: date-time |
batches[].actual_completion_at | string | null | ISO 8601 timestamp when the batch actually completedformat: date-time |
batches[].total_cost_usd | number | null | Total cost of the batch in USD≥ 0 |
total_count | integer | Total number of items across all pages≥ 0 |
next_cursor | string | null | Pass back into list() to fetch the next page. null = end. |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/ai/batch/list \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/ai/batch/list",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
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/ai/batch/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
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/ai/batch/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
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 (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/ai/batch/list", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
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/ai/batch/list"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.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("GET"), "https://api.infrai.cc/v1/ai/batch/list");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
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/ai/batch/list");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$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/ai/batch/list")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
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()
.get("https://api.infrai.cc/v1/ai/batch/list")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.5ai.batch.cancel
Cancel an ongoing batch task.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
batch_id | string | Required | The ID of the batch task to cancel. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
BatchStatus { batch_id, state, ... }| Name | Type | Description |
|---|---|---|
batch_id | string | Unique identifier for this batch jobpattern: ^batch_[A-Za-z0-9]{20,}$ |
state | "connecting" | "queued" | "in_progress" | "partial" | "completed" | "failed" | "expired" | "cancelled" | Current lifecycle state of this resource |
progress | number | Progress of the async operation (0.0 to 1.0)0–1 |
total_count | integer | Total number of items across all pages≥ 0 |
completed_count | integer | Number of completed items in the batch≥ 0 |
failed_count | integer | Number of failed items in the batch≥ 0 |
created_at | string | ISO 8601 timestamp when this resource was createdformat: date-time |
estimated_completion_at | string | null | Estimated ISO 8601 timestamp when the batch will completeformat: date-time |
actual_completion_at | string | null | ISO 8601 timestamp when the batch actually completedformat: date-time |
total_cost_usd | number | null | Total cost of the batch in USD≥ 0 |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/ai/batch/cancel/ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"batch_id": "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/ai/batch/cancel/ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'batch_id': '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/ai/batch/cancel/ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"batch_id": "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/ai/batch/cancel/ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"batch_id": "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(`{"batch_id": "sample"}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/ai/batch/cancel/ID", 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/ai/batch/cancel/ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"batch_id\": \"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/ai/batch/cancel/ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"batch_id\": \"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/ai/batch/cancel/ID");
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, "{\"batch_id\": \"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/ai/batch/cancel/ID")
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 = '{"batch_id": "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/ai/batch/cancel/ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"batch_id": "sample"}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.6ai.batch.export
Export the batch results to a jsonl or csv file and return the download task.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
batch_id | string | Required | The ID of the batch task to export.pattern: ^batch_[A-Za-z0-9]{20,}$ |
format | "jsonl" | "csv" | Optional | Export file format: jsonl or csv.default: "jsonl" |
conversation_id | string | Optional | Optional, export only the results of the specified session. |
metadata | Record<string, unknown> | Optional | Custom key-value metadata attached to the export task. |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ExportJob { export_id, state, format?, download_url?, expires_at?, created_at }| Name | Type | Description |
|---|---|---|
export_id | string | Unique identifier for this export jobpattern: ^exp_[A-Za-z0-9]{20,}$ |
state | "queued" | "in_progress" | "completed" | "failed" | "expired" | Current lifecycle state of this resource |
format | "jsonl" | "csv" | Output or input format (e.g. json, csv, png)default: "jsonl" |
download_url | string | null | Populated when state=completed.format: uri |
expires_at | string | null | ISO 8601 timestamp when this resource or token expiresformat: date-time |
created_at | string | ISO 8601 timestamp when this resource was createdformat: date-time |
error | object | null | Error message if the operation failed |
error.code | string | Stable identifier from registry.yaml. |
error.http_status | integer | HTTP status code of the webhook delivery attempt400–599 |
error.message | string | Human-readable hint. |
error.docs_url | string | Documentation URL for this error codeformat: uri |
error.code_detail | string | Sub-classification (e.g. wallet cap reason). |
error.retryable | boolean | Whether the error is retryable |
error.retry_after_ms | integer | Suggested retry delay in milliseconds≥ 0 |
error.param | string | Which parameter failed validation, if applicable. |
error.trace_id | string | Distributed tracing identifier |
error.request_id | string | Server-assigned request identifier for tracing |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/ai/batch/export/ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'# 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/ai/batch/export/ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={},
)
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/ai/batch/export/ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
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/ai/batch/export/ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
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(`{}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/ai/batch/export/ID", 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/ai/batch/export/ID"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{}"))
.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/ai/batch/export/ID");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{}", 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/ai/batch/export/ID");
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, "{}");
$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/ai/batch/export/ID")
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 = '{}'
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/ai/batch/export/ID")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.7ai.cost.estimate
Estimate the number of tokens and itemized costs of an AI request before calling.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
messages | string | ChatMessage[] | Required | The message used for estimation, which can be a string or an array of messages.≥ 1 item |
model | string | Optional | Explicit model id; skips task/prefer routing.default: "openai/gpt-4o" |
expected_output_tokens | number | Optional | The expected number of output tokens, used to estimate the output side cost.≥ 0default: 500 |
cache_strategy | "vendor" | "infrai" | "none" | Optional | Which cache layer to use.default: "vendor" |
batch_mode | boolean | Optional | Run as a batch job for a discounted rate.default: false |
tools | Tool[] | Optional | Tool/function-calling definitions. |
Returns
CostEstimate { model, vendor, vendor_region?, prompt_tokens, expected_output_tokens, breakdown }| Name | Type | Description |
|---|---|---|
model | string | Resolved model_id this estimate is for. |
vendor | string | Vendor that would serve the request. |
vendor_region | "china" | "western" | Region of the serving vendor (drives markup). |
prompt_tokens | integer | Number of tokens in the prompt≥ 0 |
expected_output_tokens | integer | Estimated number of output tokens≥ 0 |
breakdown | object | Cost breakdown by component |
breakdown.currency | "USD" | "CNY" | ISO 4217 currency code (e.g. USD, CNY) |
breakdown.input_cost | number | Input token cost in USD≥ 0 |
breakdown.output_cost | number | Output token cost in USD≥ 0 |
breakdown.markup | number | Markup applied on top of vendor cost≥ 0 |
breakdown.cache_discount | number | Discount from cache hits in USD≥ 0 |
breakdown.batch_discount | number | Discount for batch processing in USD≥ 0 |
breakdown.failover_adjustment | number | Cost adjustment due to vendor failover |
breakdown.final | number | Final cost after all adjustments in USD≥ 0 |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/ai/cost/estimate \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "system"}]}'# 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/ai/cost/estimate",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'messages': [{'role': 'system'}]},
)
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/ai/cost/estimate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"messages": [{"role": "system"}]}),
},
);
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/ai/cost/estimate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"messages": [{"role": "system"}]}),
},
);
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(`{"messages": [{"role": "system"}]}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/ai/cost/estimate", 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/ai/cost/estimate"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"messages\": [{\"role\": \"system\"}]}"))
.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/ai/cost/estimate");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"messages\": [{\"role\": \"system\"}]}", 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/ai/cost/estimate");
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, "{\"messages\": [{\"role\": \"system\"}]}");
$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/ai/cost/estimate")
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 = '{"messages": [{"role": "system"}]}'
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/ai/cost/estimate")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"messages": [{"role": "system"}]}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.8ai.cost.compare
Estimate and compare costs on multiple models for the same request.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
messages | string | ChatMessage[] | Required | The message used to compare estimates, which can be a string or an array of messages.≥ 1 item |
models | string[] | Optional | List of model IDs participating in the cost comparison. |
expected_output_tokens | number | Optional | The expected number of output tokens, used to estimate the output side cost.≥ 0default: 500 |
cache_strategy | "vendor" | "infrai" | "none" | Optional | Which cache layer to use.default: "vendor" |
batch_mode | boolean | Optional | Run as a batch job for a discounted rate.default: false |
tools | Tool[] | Optional | Tool/function-calling definitions. |
Returns
{ estimates: CostEstimate[] }Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/ai/cost/compare \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "system"}]}'# 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/ai/cost/compare",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'messages': [{'role': 'system'}]},
)
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/ai/cost/compare",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"messages": [{"role": "system"}]}),
},
);
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/ai/cost/compare",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"messages": [{"role": "system"}]}),
},
);
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(`{"messages": [{"role": "system"}]}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/ai/cost/compare", 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/ai/cost/compare"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"messages\": [{\"role\": \"system\"}]}"))
.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/ai/cost/compare");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"messages\": [{\"role\": \"system\"}]}", 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/ai/cost/compare");
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, "{\"messages\": [{\"role\": \"system\"}]}");
$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/ai/cost/compare")
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 = '{"messages": [{"role": "system"}]}'
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/ai/cost/compare")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"messages": [{"role": "system"}]}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.9ai.tokens.count
Count the number of input tokens for a group of messages under the specified model.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
messages | string | ChatMessage[] | Required | The message to count the number of tokens can be a string or a message array.≥ 1 item |
model | string | Optional | Explicit model id; skips task/prefer routing. |
tools | Tool[] | Optional | Tool/function-calling definitions. |
Returns
TokenCountResult { prompt_tokens, model }| Name | Type | Description |
|---|---|---|
prompt_tokens | integer | Total prompt tokens incl. tool-definition overhead.≥ 0 |
model | string | Tokenizer model the count was computed for. |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/ai/tokens/count \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "system"}]}'# 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/ai/tokens/count",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'messages': [{'role': 'system'}]},
)
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/ai/tokens/count",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"messages": [{"role": "system"}]}),
},
);
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/ai/tokens/count",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"messages": [{"role": "system"}]}),
},
);
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(`{"messages": [{"role": "system"}]}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/ai/tokens/count", 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/ai/tokens/count"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"messages\": [{\"role\": \"system\"}]}"))
.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/ai/tokens/count");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"messages\": [{\"role\": \"system\"}]}", 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/ai/tokens/count");
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, "{\"messages\": [{\"role\": \"system\"}]}");
$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/ai/tokens/count")
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 = '{"messages": [{"role": "system"}]}'
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/ai/tokens/count")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"messages": [{"role": "system"}]}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.10ai.image.upscale
Magnify the image by 2x or 4x losslessly.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
image | string | Required | Source image to be enlarged, URL or base64.e.g. data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg== |
factor | 2 | 4 | Optional | Magnification, 2 or 4.default: 2 |
idempotency_key | string | Optional | Optional dedup key; identical retries return the same result. |
Returns
ImageUpscaleResult { image, original_size, new_size }| Name | Type | Description |
|---|---|---|
image | object | Image data or reference for processing |
image.b64_json | string | Base64-encoded bytes of the upscaled image (inline; stateless passthrough). |
image.width | integer | -≥ 1 |
image.height | integer | -≥ 1 |
image.mime_type | string | -e.g. image/png |
image.image_id | string | null | Set only when the caller passed store:true; null for the default stateless transform. |
image.url | string | null | Infrai CDN URL when stored; null by default.format: uri |
original_size | string | Original image dimensions before transformatione.g. 1024x1024 |
new_size | string | New image dimensions after transformatione.g. 2048x2048 |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X POST https://api.infrai.cc/v1/ai/image/upscale \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="}'# 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/ai/image/upscale",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'image': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=='},
)
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/ai/image/upscale",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="}),
},
);
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/ai/image/upscale",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="}),
},
);
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(`{"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="}`)
req, _ := http.NewRequest("POST", "https://api.infrai.cc/v1/ai/image/upscale", 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/ai/image/upscale"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\"image\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==\"}"))
.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/ai/image/upscale");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
req.Content = new StringContent("{\"image\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==\"}", 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/ai/image/upscale");
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, "{\"image\": \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==\"}");
$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/ai/image/upscale")
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 = '{"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="}'
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/ai/image/upscale")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.header("Content-Type", "application/json")
.body(r#"{"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="}"#)
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}2.11ai.tts.voices
Paginated list of sounds available for text-to-speech.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
vendor | string | Optional | Pin a specific vendor instead of auto-routing. |
Returns
VoiceListResult { items, count, next_cursor? }| Name | Type | Description |
|---|---|---|
items | object[] | Array of result items in this page |
items[].voice_id | string | - |
items[].vendor | string | - |
items[].name | string | null | - |
items[].model | string | null | The vendor model this voice should be paired with for synthesis. |
items[].language | string | null | BCP-47 language tag. |
items[].languages | string[] | null | Supported languages or locales published by the vendor for this voice. |
items[].gender | string | null | - |
items[].preview_url | string | null | -format: uri |
items[].is_default | boolean | True if this is the vendor's default voice used by synthesize() when none is pinned. |
next_cursor | string | null | Pass back into voices() to fetch the next page. null = end. |
count | integer | Total number of items across all pages≥ 0 |
Example
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."curl -X GET https://api.infrai.cc/v1/ai/tts/voices \
-H "Authorization: Bearer $INFRAI_API_KEY"# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/ai/tts/voices",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
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/ai/tts/voices",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
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/ai/tts/voices",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
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 (
"fmt"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET", "https://api.infrai.cc/v1/ai/tts/voices", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("INFRAI_API_KEY"))
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/ai/tts/voices"))
.header("Authorization", "Bearer " + System.getenv("INFRAI_API_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.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("GET"), "https://api.infrai.cc/v1/ai/tts/voices");
var key = Environment.GetEnvironmentVariable("INFRAI_API_KEY");
req.Headers.Add("Authorization", "Bearer " + key);
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/ai/tts/voices");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Authorization: Bearer " . getenv("INFRAI_API_KEY"),
]);
$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/ai/tts/voices")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{ENV['INFRAI_API_KEY']}"
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()
.get("https://api.infrai.cc/v1/ai/tts/voices")
.header("Authorization", format!("Bearer {}", env::var("INFRAI_API_KEY")?))
.send()
.await?;
println!("{}", resp.text().await?);
Ok(())
}Advanced: pin a vendor
By default infrai routes each call to the best available provider — you do not pick a vendor. As an escape hatch, this capability accepts an optional vendor parameter to pin one specific provider. Every live vendor for this capability is available in real time from the discovery endpoint for the capability id — see the discovery API.
GET /v1/discovery/{capability}ai.image.upscale
ai.tts.voices
3. All capabilities
Every routed capability in this module — the complete public REST contract. The methods above are the guided walkthrough; this index is the full reference.
ai.asrPOST /v1/audio/transcriptionsSpeech-to-text — transcribe an audio file (multipart or base64 JSON).
Parameters (4)
| Name | Type | Required | Description |
|---|---|---|---|
file | string | Required | Audio file to transcribe when using multipart/form-data.format: binary |
model | "auto" | "cheapest" | "smartest" | string | Optional | Model to use — either a routing MODE (infrai picks the model for you) or a concrete model id to pin. Modes: 'auto' — Default. Balanced routing across healthy vendors — same tier as `prefer: balanced`.; 'cheapest' — Cheapest healthy model that serves the task — same tier as `prefer: cheapest`.; 'smartest' — Flagship-tier model — same tier as `prefer: smartest`. To pin instead, pass any id a verified vendor serves ('gpt-4o-mini'), or 'vendor/model' ('dashscope/qwen-plus') to pin the vendor too — GET /v1/models returns the live servable set. Omitted or empty behaves as 'auto'.default: "auto"e.g. auto |
language | string | Optional | ISO-639-1 language hint. |
response_format | "json" | "text" | "srt" | "verbose_json" | "vtt" | Optional |
ai.batch.cancelPOST /v1/ai/batch/cancel/{id}Cancel an in-progress batch job (idempotent).
Parameters (3)
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | Path parameter. |
batch_id | string | Required | Id of the batch job to cancel. |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
ai.batch.exportPOST /v1/ai/batch/export/{id}Export batch results to a JSONL or CSV file and return a download job.
Parameters (6)
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | Path parameter. |
batch_id | string | null | Optional | Target batch for ai.batch.export.pattern: ^batch_[A-Za-z0-9]{20,}$ |
conversation_id | string | null | Optional | Target conversation for ai.chat.history.export; null = all history. |
format | "jsonl" | "csv" | Optional | Output or input format (e.g. json, csv, png)default: "jsonl" |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
metadata | object | null | Optional | Arbitrary key-value metadata attached to this resource |
ai.batch.listGET /v1/ai/batch/listList all batch jobs on the account with pagination.
No request parameters.
ai.batch.resultsGET /v1/ai/batch/results/{id}Fetch per-item results of a batch job with pagination.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | Path parameter. |
ai.batch.statusGET /v1/ai/batch/status/{id}Get a batch job's status, progress, and completed/failed counts.
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
id | string | Required | Path parameter. |
ai.batch.submitPOST /v1/ai/batch/submitSubmit a batch of AI requests as one async batch job (billed at cost pass-through with no markup).
Parameters (5)
| Name | Type | Required | Description |
|---|---|---|---|
requests | object[] | Required | Each item is a ChatRequest / EmbeddingRequest payload.≥ 1 item |
batch_timeout | string | Optional | Maximum wall-clock the batch may run before expiring.default: "24h"e.g. 1h |
metadata | object | null | Optional | Arbitrary key-value metadata attached to this resource |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
store | boolean | Optional | Opt in to RETAIN the produced asset/record in Infrai's own store (default false = stateless passthrough: process, return inline, keep nothing). When true, Infrai persists the asset, bills a self-hosted storage line item and applies a retention TTL — and only then do the *.list/get/delete read caps see it.default: false |
ai.chatPOST /v1/chat/completionsChat completions — text, vision and tool calls, with streaming.
Parameters (8)
| Name | Type | Required | Description |
|---|---|---|---|
model | "auto" | "cheapest" | "smartest" | string | Optional | Model to use — either a routing MODE (infrai picks the model for you) or a concrete model id to pin. Modes: 'auto' — Default. Balanced routing across healthy vendors — same tier as `prefer: balanced`.; 'cheapest' — Cheapest healthy model that serves the task — same tier as `prefer: cheapest`.; 'smartest' — Flagship-tier model — same tier as `prefer: smartest`. To pin instead, pass any id a verified vendor serves ('gpt-4o-mini'), or 'vendor/model' ('dashscope/qwen-plus') to pin the vendor too — GET /v1/models returns the live servable set. Omitted or empty behaves as 'auto'.default: "auto"e.g. auto |
messages | object[] | Required | OpenAI chat messages: a list of {role, content}. |
temperature | number | Optional | |
max_tokens | integer | Optional | |
top_p | number | Optional | |
stream | boolean | Optional | Server-Sent Events streaming when true. |
tools | object[] | Optional | |
response_format | object | Optional |
ai.cost.comparePOST /v1/ai/cost/compareEstimate and compare the cost of the same request across multiple models.
Parameters (7)
| Name | Type | Required | Description |
|---|---|---|---|
messages | object[] | Required | Chat messages to price (same shape as ai.chat); cost is estimated from their token count.≥ 1 item |
model | string | null | Optional | Single model to estimate. Used by ai.cost.estimate. Explicit model_id is allowed here (selection semantics).default: "openai/gpt-4o" |
models | string[] | null | Optional | Models to compare. Used by ai.cost.compare; result is sorted ascending by final cost. |
expected_output_tokens | integer | Optional | Assumed completion length for the estimate.≥ 0default: 500 |
cache_strategy | "vendor" | "infrai" | "none" | Optional | Cache strategy hint (none, exact, semantic)default: "vendor" |
batch_mode | boolean | Optional | When true, applies the 50% batch discount to the estimate.default: false |
tools | object[] | null | Optional | Tool/function definitions for the model to call |
ai.cost.estimatePOST /v1/ai/cost/estimateEstimate token counts and itemized cost for an AI request before calling it.
Parameters (7)
| Name | Type | Required | Description |
|---|---|---|---|
messages | object[] | Required | Chat messages to price (same shape as ai.chat); cost is estimated from their token count.≥ 1 item |
model | string | null | Optional | Single model to estimate. Used by ai.cost.estimate. Explicit model_id is allowed here (selection semantics).default: "openai/gpt-4o" |
models | string[] | null | Optional | Models to compare. Used by ai.cost.compare; result is sorted ascending by final cost. |
expected_output_tokens | integer | Optional | Assumed completion length for the estimate.≥ 0default: 500 |
cache_strategy | "vendor" | "infrai" | "none" | Optional | Cache strategy hint (none, exact, semantic)default: "vendor" |
batch_mode | boolean | Optional | When true, applies the 50% batch discount to the estimate.default: false |
tools | object[] | null | Optional | Tool/function definitions for the model to call |
ai.embedPOST /v1/embeddingsText embeddings for search and RAG.
Parameters (4)
| Name | Type | Required | Description |
|---|---|---|---|
model | "auto" | "cheapest" | "smartest" | string | Optional | Model to use — either a routing MODE (infrai picks the model for you) or a concrete model id to pin. Modes: 'auto' — Default. Balanced routing across healthy vendors — same tier as `prefer: balanced`.; 'cheapest' — Cheapest healthy model that serves the task — same tier as `prefer: cheapest`.; 'smartest' — Flagship-tier model — same tier as `prefer: smartest`. To pin instead, pass any id a verified vendor serves ('gpt-4o-mini'), or 'vendor/model' ('dashscope/qwen-plus') to pin the vendor too — GET /v1/models returns the live servable set. Omitted or empty behaves as 'auto'.default: "auto"e.g. auto |
input | string | string[] | Required | Text string or array of strings to embed. |
encoding_format | "float" | "base64" | Optional | |
dimensions | integer | Optional |
ai.imagePOST /v1/images/generationsImage generation from a text prompt.
Parameters (5)
| Name | Type | Required | Description |
|---|---|---|---|
model | "auto" | "cheapest" | "smartest" | string | Optional | Model to use — either a routing MODE (infrai picks the model for you) or a concrete model id to pin. Modes: 'auto' — Default. Balanced routing across healthy vendors — same tier as `prefer: balanced`.; 'cheapest' — Cheapest healthy model that serves the task — same tier as `prefer: cheapest`.; 'smartest' — Flagship-tier model — same tier as `prefer: smartest`. To pin instead, pass any id a verified vendor serves ('gpt-4o-mini'), or 'vendor/model' ('dashscope/qwen-plus') to pin the vendor too — GET /v1/models returns the live servable set. Omitted or empty behaves as 'auto'.default: "auto"e.g. auto |
prompt | string | Required | Text prompt describing the image. |
n | integer | Optional | |
size | string | Optional | Image size such as '1024x1024'. |
response_format | "url" | "b64_json" | Optional |
ai.image.upscalePOST /v1/ai/image/upscaleUpscale an image losslessly by 2x or 4x with an AI model (idempotent). To transform an EXISTING image otherwise use the image.* module.
Parameters (8)
| Name | Type | Required | Description |
|---|---|---|---|
image | string | Required | URL / file path / base64 of the source image.e.g. data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg== |
factor | 2 | 4 | Optional | Upscale factor (e.g. 2 or 4)default: 2 |
model | string | null | Optional | Model identifier to use for generation |
vendor | string | null | Optional | Vendor that handled or will handle this request |
timeout_seconds | integer | Optional | Maximum execution time in seconds1–600default: 120 |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
metadata | object | null | Optional | Arbitrary key-value metadata attached to this resource |
store | boolean | Optional | Opt in to RETAIN the produced asset/record in Infrai's own store (default false = stateless passthrough: process, return inline, keep nothing). When true, Infrai persists the asset, bills a self-hosted storage line item and applies a retention TTL — and only then do the *.list/get/delete read caps see it.default: false |
ai.models.getGET /v1/models/{model}Retrieve one model's details (pricing, context, availability).
Parameters (1)
| Name | Type | Required | Description |
|---|---|---|---|
model | string | Required | Path parameter. |
ai.models.listGET /v1/modelsList every model a verified, routable vendor serves.
No request parameters.
ai.moderationPOST /v1/moderationsClassify whether content violates usage policy.
Parameters (2)
| Name | Type | Required | Description |
|---|---|---|---|
model | "auto" | "cheapest" | "smartest" | string | Optional | Model to use — either a routing MODE (infrai picks the model for you) or a concrete model id to pin. Modes: 'auto' — Default. Balanced routing across healthy vendors — same tier as `prefer: balanced`.; 'cheapest' — Cheapest healthy model that serves the task — same tier as `prefer: cheapest`.; 'smartest' — Flagship-tier model — same tier as `prefer: smartest`. To pin instead, pass any id a verified vendor serves ('gpt-4o-mini'), or 'vendor/model' ('dashscope/qwen-plus') to pin the vendor too — GET /v1/models returns the live servable set. Omitted or empty behaves as 'auto'.default: "auto"e.g. auto |
input | string | string[] | Required | Text string or array of strings to moderate. |
ai.rerankPOST /v1/ai/rerankReorder a list of candidate documents by relevance to a query, returning each candidate's original index and a vendor relevance score. Real vendor dispatch: Cohere rerank, Qwen/DashScope gte-rerank. Replaces the previous original-order mock.
Parameters (5)
| Name | Type | Required | Description |
|---|---|---|---|
query | string | Required | Search query string for reranking≥ 1 chars |
candidates | string[] | Required | Documents to score against the query; the response returns them reordered by relevance.≥ 1 item |
top_k | integer | Optional | Number of top results to return≥ 1default: 10 |
model | string | Optional | Optional model pin (e.g. rerank-english-v3.0, gte-rerank). |
vendor | "cohere" | "jina" | "qwen" | Optional | Optional vendor pin. |
ai.tokens.countPOST /v1/ai/tokens/countCount input tokens for a set of messages under a given model.
Parameters (3)
| Name | Type | Required | Description |
|---|---|---|---|
messages | object[] | Required | Chat messages to tokenize (same shape as ai.chat), including tool-definition overhead.≥ 1 item |
model | string | null | Optional | Tokenizer model; null = default. Determines which encoding is used. |
tools | object[] | null | Optional | Tool definitions; their serialized overhead is included in the count. |
ai.ttsPOST /v1/audio/speechText-to-speech — synthesize spoken audio (binary body).
Parameters (5)
| Name | Type | Required | Description |
|---|---|---|---|
model | "auto" | "cheapest" | "smartest" | string | Optional | Model to use — either a routing MODE (infrai picks the model for you) or a concrete model id to pin. Modes: 'auto' — Default. Balanced routing across healthy vendors — same tier as `prefer: balanced`.; 'cheapest' — Cheapest healthy model that serves the task — same tier as `prefer: cheapest`.; 'smartest' — Flagship-tier model — same tier as `prefer: smartest`. To pin instead, pass any id a verified vendor serves ('gpt-4o-mini'), or 'vendor/model' ('dashscope/qwen-plus') to pin the vendor too — GET /v1/models returns the live servable set. Omitted or empty behaves as 'auto'.default: "auto"e.g. auto |
input | string | Required | The text to synthesize. |
voice | string | Required | Voice id such as 'alloy'. |
response_format | string | Optional | Audio format such as 'mp3' or 'wav'. |
speed | number | Optional |
ai.tts.voicesGET /v1/ai/tts/voicesList available text-to-speech voices with pagination.
No request parameters.
ai.voice.sessionPOST /v1/ai/voice/sessionMint a short-lived token for an AI realtime VOICE/multimodal conversation session (e.g. OpenAI Realtime). NOT pub/sub channel auth — see realtime.token.issue.
Parameters (6)
| Name | Type | Required | Description |
|---|---|---|---|
model | string | null | Optional | Realtime voice model; null lets the server pick a default. |
voice | string | null | Optional | Voice id/name to use for the session. |
vendor | string | null | Optional | Pin to a specific vendor; disables failover. |
instructions | string | null | Optional | System instructions for the realtime session. |
modalities | string[] | null | Optional | Enabled modalities (e.g. text, audio). |
idempotency_key | string | null | Optional | Client-provided idempotency key; prevents duplicate execution on retry |
4. End-to-end example
A production-style walkthrough of this module: configure once, then run the flow. It exercises most of the module's APIs.
A copy-paste-runnable single-file Python program (stdlib only, no SDK): set your INFRAI_API_KEY, run it, and walk this module's core flow with REAL billed calls — later steps reuse real fields returned by earlier ones. The 12-line helper is the entire integration.
#!/usr/bin/env python3
"""Infrai · ai-runtime — runnable real-app example (single file, zero deps).
Copy this file, set your key, run it: every step is a REAL call to
api.infrai.cc, billed at the real (tiny) per-call price, printing the
live JSON response. Get a key at https://infrai.cc/login (Google/
GitHub sign-in grants $2 free credit); add funds at
https://infrai.cc/billing. No SDK — the 12-line helper below is the
entire integration."""
import json
import os
from urllib import error, request
KEY = os.environ.get("INFRAI_API_KEY") or "ifr_..." # <- your key
BASE = "https://api.infrai.cc"
# Same raw HTTPS POST/GET as every per-method example on this page —
# wrapped once for reuse. There is nothing else to it: no SDK.
def infrai(method, path, body=None):
req = request.Request(
BASE + path, method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": f"Bearer {KEY}",
"Content-Type": "application/json"})
try:
with request.urlopen(req, timeout=60) as r:
return json.loads(r.read())
except error.HTTPError as e:
return json.loads(e.read())
def show(label, resp):
print(f"\n== {label} ==")
print(json.dumps(resp, indent=2, ensure_ascii=False))
return resp
# 1) chat — POST /v1/chat/completions (OpenAI-compatible)
ask1 = input("Ask the model anything: ").strip()
r1 = show("chat", infrai("POST", "/v1/chat/completions", {"model":"auto","messages":[{"role":"user","content":ask1}]}))
# 2) embeddings — POST /v1/embeddings (OpenAI-compatible)
r2 = show("embeddings", infrai("POST", "/v1/embeddings", {"model":"auto","input":"Infrai is the standard library for AI-built apps."}))
# 3) ai.cost.estimate — POST /v1/ai/cost/estimate · Estimate token counts and itemized cost for an AI request before calling it.
r3 = show("ai.cost.estimate", infrai("POST", "/v1/ai/cost/estimate", {"messages":[{"role":"system"}]}))
One-time prep (each example is assumed to be complete):
# No SDK to install — every call is a plain HTTPS request.
# Get a project key by signing in at https://infrai.cc/login (Google/GitHub gives
# you $2 free credit; email sign-in starts at $0). On 402 INSUFFICIENT_CREDIT, add
# funds at https://infrai.cc/billing (or POST /v1/account/topup and open the
# returned checkout_url).
export INFRAI_API_KEY="ifr_..."# 1) Auth: every call is a raw HTTPS request to the Infrai gateway carrying
# only your project key. No SDK, no install.
# Get your key: sign in with Google/GitHub at https://infrai.cc/login for a
# project key + $2 free credit (email sign-in starts at $0). On 402
# INSUFFICIENT_CREDIT, add funds at https://infrai.cc/billing (or POST
# /v1/account/topup and open the returned checkout_url).
export INFRAI_API_KEY="ifr_..." # from https://infrai.cc/login
# 2) ai.batch.submit
curl -X POST https://api.infrai.cc/v1/ai/batch/submit \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"requests": [{}]}'
# 3) ai.batch.status
curl -X GET https://api.infrai.cc/v1/ai/batch/status/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 4) ai.batch.results
curl -X GET https://api.infrai.cc/v1/ai/batch/results/ID \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 5) ai.batch.list
curl -X GET https://api.infrai.cc/v1/ai/batch/list \
-H "Authorization: Bearer $INFRAI_API_KEY"
# 6) ai.batch.cancel
curl -X POST https://api.infrai.cc/v1/ai/batch/cancel/ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"batch_id": "sample"}'
# 7) ai.batch.export
curl -X POST https://api.infrai.cc/v1/ai/batch/export/ID \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'
# 8) ai.cost.estimate
curl -X POST https://api.infrai.cc/v1/ai/cost/estimate \
-H "Authorization: Bearer $INFRAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{"messages": [{"role": "system"}]}'
# 1) Auth: every call is a raw HTTPS request carrying only your project key.
# No SDK to install — just the `requests` library.
import os, requests
BASE = "https://api.infrai.cc"
HEADERS = {
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
"Content-Type": "application/json",
}
# 2) ai.batch.submit
# 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/ai/batch/submit",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'requests': [{}]},
)
resp.raise_for_status()
print(resp.json())
# 3) ai.batch.status
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/ai/batch/status/ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())
# 4) ai.batch.results
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/ai/batch/results/ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())
# 5) ai.batch.list
# Zero-install REST call — no SDK required (short-term the API is REST-only).
import os, requests
resp = requests.get(
"https://api.infrai.cc/v1/ai/batch/list",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
)
resp.raise_for_status()
print(resp.json())
# 6) ai.batch.cancel
# 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/ai/batch/cancel/ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'batch_id': 'sample'},
)
resp.raise_for_status()
print(resp.json())
# 7) ai.batch.export
# 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/ai/batch/export/ID",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={},
)
resp.raise_for_status()
print(resp.json())
# 8) ai.cost.estimate
# 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/ai/cost/estimate",
headers={
"Authorization": f"Bearer {os.environ['INFRAI_API_KEY']}",
},
json={'messages': [{'role': 'system'}]},
)
resp.raise_for_status()
print(resp.json())
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch().
const BASE = "https://api.infrai.cc";
const HEADERS = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) ai.batch.submit
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/submit",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"requests": [{}]}),
},
);
console.log(await resp.json());
// 3) ai.batch.status
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/status/ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 4) ai.batch.results
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/results/ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 5) ai.batch.list
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
console.log(await resp.json());
// 6) ai.batch.cancel
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/cancel/ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"batch_id": "sample"}),
},
);
console.log(await resp.json());
// 7) ai.batch.export
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/export/ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
console.log(await resp.json());
// 8) ai.cost.estimate
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/cost/estimate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"messages": [{"role": "system"}]}),
},
);
console.log(await resp.json());
// 1) Auth: every call is a raw HTTPS request carrying only your project key.
// No SDK to install — just the built-in fetch(), typed.
const BASE = "https://api.infrai.cc";
const HEADERS: Record<string, string> = {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
};
// 2) ai.batch.submit
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/submit",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"requests": [{}]}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 3) ai.batch.status
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/status/ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 4) ai.batch.results
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/results/ID",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 5) ai.batch.list
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/list",
{
method: "GET",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
},
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 6) ai.batch.cancel
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/cancel/ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"batch_id": "sample"}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 7) ai.batch.export
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/batch/export/ID",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
// 8) ai.cost.estimate
// Zero-install REST call — no SDK required (short-term the API is REST-only).
const resp = await fetch(
"https://api.infrai.cc/v1/ai/cost/estimate",
{
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.INFRAI_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({"messages": [{"role": "system"}]}),
},
);
if (!resp.ok) throw new Error(`infrai ${resp.status}`);
const data: unknown = await resp.json();
console.log(data);
5. Developer guides
Move from endpoint details to complete workflows, production patterns and troubleshooting guides verified against the live API.
AI Runtime developer guides