Quickstart
Go from zero to your first Tensoras.ai API call in under five minutes.
1. Get an API Key
- Sign up or log in at cloud.tensoras.ai.
- Navigate to Console > API Keys.
- Click Create Key, give it a name, and copy the key. It starts with
tns_.
Important: Store your API key securely. You will not be able to view it again after creation.
Set it as an environment variable so the SDKs pick it up automatically:
export TENSORAS_API_KEY="tns_your_key_here"2. Install the SDK
pip install tensorasYou can also use the OpenAI SDK directly — see OpenAI-Compatible Usage.
3. Make Your First Request
Send a chat completion request to Llama 3.3 70B.
from tensoras import Tensoras
client = Tensoras() # reads TENSORAS_API_KEY from env
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is retrieval-augmented generation?"},
],
)
print(response.choices[0].message.content){
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "llama-3.3-70b",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Retrieval-augmented generation (RAG) is a technique that enhances LLM responses by retrieving relevant documents from an external knowledge base and including them in the prompt context. This allows the model to ground its answers in specific, up-to-date information rather than relying solely on its training data."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 28,
"completion_tokens": 52,
"total_tokens": 80
}
}4. Try Streaming
Stream tokens as they are generated for a responsive user experience.
from tensoras import Tensoras
client = Tensoras()
stream = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "user", "content": "Write a haiku about open-source AI."},
],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)
print() # newline after stream completesWeights shared with the world
Silicon dreams set free to learn
All may shape the mindSee the full Streaming guide for SSE details, error handling, and cancellation.
5. Try RAG with Knowledge Bases
Tensoras Knowledge Bases let you upload documents and query them alongside a chat completion. The model receives relevant chunks as context and can return citations.
Step 1: Create a Knowledge Base
from tensoras import Tensoras
client = Tensoras()
kb = client.knowledge_bases.create(
name="product-docs",
description="Internal product documentation",
)
print(kb.id) # e.g. "kb_a1b2c3d4"Step 2: Upload a File
data_source = client.knowledge_bases.data_sources.create(
knowledge_base_id=kb.id,
type="file_upload",
file=open("product-guide.pdf", "rb"),
)
# Wait for ingestion to complete
print(data_source.status) # "processing" -> "completed"Step 3: Query with RAG
Pass the knowledge_bases parameter in your chat completion request. Tensoras retrieves relevant chunks using hybrid search (vector + keyword) and injects them as context.
response = client.chat.completions.create(
model="llama-3.3-70b",
messages=[
{"role": "user", "content": "How do I reset my password?"},
],
knowledge_bases=["kb_a1b2c3d4"],
)
print(response.choices[0].message.content)
# Access citations
for citation in response.citations:
print(f"Source: {citation.source}, Score: {citation.score:.3f}")To reset your password, go to Settings > Account > Security and click
"Reset Password." You will receive a confirmation email with a reset link
that expires after 24 hours.
Source: product-guide.pdf, Score: 0.934See the RAG Overview, Hybrid Search, Citations, and Connectors guides for more.
6. Next Steps
You are all set. Here is where to go next depending on what you want to build:
- Streaming — real-time token delivery over SSE
- Tool Calling — let the model invoke functions
- Structured Outputs — enforce JSON schemas on responses
- Reasoning — chain-of-thought with DeepSeek R1
- API Reference — full endpoint specs
- Python SDK | Node.js SDK — client library docs
- Integrations — LangChain, LlamaIndex, Vercel AI SDK, and more
- Migrate from OpenAI — drop-in migration guide