Python SDK Documentation
Table of Contents
Copy-paste essentials
Install, credentials, env vars
Action, Knowledge, Chat
LLM columns, RAG, prompting
Streaming, file upload
WHERE, pagination, search
Batch updates
Batch deletes
List, schema, duplicate
Embeddings, RAG
Conversation history
Upload, presigned URLs
Custom code, images, audio
Chat completions, embeddings
Unwrapping row values
Retry patterns
Parallel processing
Deprecated methods
End-to-end code
JamAI Base is a backend-as-a-service for AI applications. You define tables with columns that automatically process data through AI pipelines.
Column Types
Input
Your data
dtype="str", "file", "image", "audio"
LLM
AI generates content
gen_config=t.LLMGenConfig(...)
Python
Custom logic/validation
gen_config=t.PythonGenConfig(...)
Data Types: str (text), file (generic), image (.jpeg/.jpg/.png/.gif/.webp), audio (.mp3/.wav)
How It Works
Define a table with input + AI columns
Add a row with input data
AI columns auto-generate based on your prompts
Read the completed row with all outputs
Available Models
Row Structure
Every row returned from list_table_rows contains:
Value Wrapping Context:
SDK reads (
list_table_rows,get_table_row): Values ARE wrapped → userow['col']['value']Python Columns (
rowdict insidePythonGenConfig): Values are NOT wrapped → userow['col']directly
QUICK REFERENCE
1. SETUP
Install
Python Version (>= 3.12)
Get Credentials
Sign up: https://cloud.jamaibase.com/
Create project
Get PAT key: Click on your user name on top right corner > ⚙ Account Settings > Create a Personal Access Token
Get Project ID: from project URL
Initialize Client
.env File
Note: When using JamAI() without arguments, it auto-loads from environment variables.
2. TABLE TYPES
action
AI chains, document processing
create_action_table()
knowledge
RAG, embeddings, vector search
create_knowledge_table()
chat
Conversational AI with context
create_chat_table()
3. ACTION TABLES (Most Common)
Create
Column Reference Syntax
Use ${column_name} in prompts to reference other columns. At runtime, each reference is replaced with the corresponding cell value from the current row.
How LLM Columns Work
The LLM Column will:
Gather prompts - System Prompt and Prompt (which can reference upstream columns)
Optional RAG - Augment prompt with references from a Knowledge Table
Send to LLM - With your chosen generation settings (model, temperature, max_tokens)
Write response - Model's response becomes the cell value
LLM Generation Settings
model
LLM model to use (e.g., openai/gpt-5.2)
system_prompt
Passed as-is as system message. Define role, style, global instructions
prompt
Main user message with ${column} references
temperature
Controls randomness (0.0-2.0)
max_tokens
Maximum output length
RAG (Retrieval Augmented Generation)
Link an LLM column to a Knowledge Table for grounded responses. See Section 9 for full Knowledge Table setup.
RAG Flow:
Formulate query → LLM generates retrieval query from your Prompt
Retrieve → Fetch relevant rows from Knowledge Table
Rerank → Optional reranking model (RRF Ranker by default)
Inject → Top-k references added to prompt
Cite → Optional inline citations:
[@ref0; @ref1; @ref2]
Multi-turn Chat in Action Tables
Enable multi-turn chat to use previous rows as conversation history:
With multi-turn enabled, each generation sees all previous rows as context.
Prompting Tips
Separate column references using XML tags or Markdown headings:
4. ADD ROWS
Non-Streaming (Wait for Complete Response)
Streaming (Real-time Output)
With File Upload
Get Row ID After Adding (Non-Streaming)
Get Row ID After Adding (Streaming)
5. READ ROWS
Basic List
With WHERE Filter
Select Specific Columns
Full-Text Search
Pagination (REQUIRED for >100 rows)
Get Single Row
6. UPDATE ROWS
7. DELETE ROWS
8. TABLE OPERATIONS
List Tables
Get Schema
Delete Table
Duplicate Table
Check If Table Exists
Safe Table Creation (Delete if Exists)
9. KNOWLEDGE TABLES (RAG)
Create
Add Data
Embed File
Create RAG Action Table
10. CHAT TABLES
Create
Chat (Streaming)
How Chat History Works
Chat tables automatically maintain conversation history. Each row added becomes part of the context for subsequent rows.
Note: Each chat table is a separate conversation. Create multiple tables for multiple users/sessions.
11. FILE OPERATIONS
Upload
Get Presigned URL (for display)
12. PYTHON COLUMNS
Basic Concept
The Python Column lets you generate or transform cell values using custom Python code. All upstream columns (columns to the left) are passed as a dictionary named row.
Keys in
roware column names (strings, case-sensitive)Values are the corresponding cell values for that row
Assign result to
row["Python Column Name"]to set the output
Syntax
Preinstalled Libraries
The following libraries are available:
aiohttp
Async HTTP client
audioop-lts
Audio operations
beautifulsoup4
HTML/XML parsing
httpx
HTTP requests
matplotlib
Plotting/visualization
numpy
Numerical computing
opencv-python
Computer vision
orjson
Fast JSON parsing
pandas
Data manipulation
Pillow
Image processing
pyyaml
YAML parsing
regex
Advanced regex
requests
HTTP requests
ruamel.yaml
YAML parsing
scikit-image
Image processing
simplejson
JSON parsing
soundfile
Audio file I/O
sympy
Symbolic math
tiktoken
Token counting
Column Data Types
str
Text output
file
Generic file
image
Image file (.jpeg, .jpg, .png, .gif, .webp)
audio
Audio file (.mp3, .wav)
Working with Images
When an upstream column contains an image, its value in row is raw binary data (bytes).
Working with Audio
When an upstream column contains audio, its value in row is also raw binary data (bytes).
Making Web Requests
Use httpx to fetch data from the web:
Example: Name Matching
13. DIRECT API (No Tables)
Chat Completions
Embeddings
Model Info
14. VALUE EXTRACTION (CRITICAL)
Row values are WRAPPED. Always extract:
JSON with Confidence Scores
15. ERROR HANDLING
Common Errors Table
limit > 100
Use pagination, max is 100
Table not found
Check table name, create if needed
Value is dict
Use get_value() helper
JSONDecodeError
Wrap in try-except
LLM empty
Wait 15-30s or use streaming
WHERE syntax
Use "col" = 'val' (double/single quotes)
Model overloaded
Retry with exponential backoff
Error Handling Pattern
Handle Empty LLM Response
Streaming Error Handling
16. ASYNC OPERATIONS
Async Client
Parallel Processing with Async
17. REQUEST TYPES
Current vs Deprecated Methods
t.MultiRowAddRequest
t.RowAddRequest
t.MultiRowUpdateRequest
t.RowUpdateRequest
t.MultiRowDeleteRequest
t.RowDeleteRequest
jamai.model_ids()
jamai.model_names()
Deprecated methods still work but will show warnings. Update your code to use the current methods.
18. COMPLETE EXAMPLE
End-to-end example: Create table, add row, read result, cleanup.
QUICK COPY-PASTE
Last updated
Was this helpful?