Quickstart
Get up and running with Tensor Machine in Python, Node.js, or cURL — in under 2 minutes.
Prerequisites
You need a Tensor Machine API key. Get one free at tensormachine.ai.
Python
Install the OpenAI SDK — Tensor Machine is fully OpenAI-compatible:
pip install openaifrom openai import OpenAI
client = OpenAI(
api_key="tx_live_...", # your Tensor Machine API key
base_url="https://edge.tensormachine.ai/v1",
)
response = client.chat.completions.create(
model="z-ai/glm-5.2",
messages=[
{
"role": "system",
"content": "You are a helpful assistant for Indian enterprises."
},
{
"role": "user",
"content": "Summarise the DPDP Act 2023 in three bullet points."
}
],
max_tokens=256,
)
print(response.choices[0].message.content)Streaming (Python)
stream = client.chat.completions.create(
model="z-ai/glm-5.2",
messages=[{"role": "user", "content": "Tell me about India's AI ecosystem."}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)Node.js / TypeScript
npm install openaiimport OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.TENSORMACHINE_API_KEY,
baseURL: 'https://edge.tensormachine.ai/v1',
});
async function main() {
const response = await client.chat.completions.create({
model: 'minimax/minimax-m3',
messages: [
{ role: 'user', content: 'What are the top 5 AI use cases for Indian banks?' }
],
});
console.log(response.choices[0].message.content);
}
main();Streaming (Node.js)
const stream = await client.chat.completions.create({
model: 'minimax/minimax-m3',
messages: [{ role: 'user', content: 'Explain GST filing in simple terms.' }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}cURL
curl https://edge.tensormachine.ai/v1/chat/completions \
-H "Authorization: Bearer $TENSORMACHINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "z-ai/glm-5.2",
"messages": [
{ "role": "user", "content": "Hello from India!" }
],
"max_tokens": 128
}'List available models
curl https://edge.tensormachine.ai/v1/models \
-H "Authorization: Bearer $TENSORMACHINE_API_KEY"Environment variables
Never hardcode your API key. Use environment variables:
# .env (add to .gitignore)
TENSORMACHINE_API_KEY=tx_live_...import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TENSORMACHINE_API_KEY"],
base_url="https://edge.tensormachine.ai/v1",
)Workspaces & organizations
Every account has a personal workspace and can belong to work organizations — one login, separate wallets, separate teams, switchable in the console.
Models Reference
How models work on the Tensor Machine API — a single OpenAI-compatible endpoint, India-resident. The live catalogue and current pricing are on the website.