Python SDK Documentation

Table of Contents

Section
Topic

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

Type
Purpose
Example

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

1

Define a table with input + AI columns

2

Add a row with input data

3

AI columns auto-generate based on your prompts

4

Read the completed row with all outputs

Available Models

Row Structure

Every row returned from list_table_rows contains:


QUICK REFERENCE


1. SETUP

Install

Python Version (>= 3.12)

Get Credentials

1

Sign up: https://cloud.jamaibase.com/

2

Create project

3

Get PAT key: Click on your user name on top right corner > ⚙ Account Settings > Create a Personal Access Token

4

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

Type
Use Case
Create Method

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:

  1. Gather prompts - System Prompt and Prompt (which can reference upstream columns)

  2. Optional RAG - Augment prompt with references from a Knowledge Table

  3. Send to LLM - With your chosen generation settings (model, temperature, max_tokens)

  4. Write response - Model's response becomes the cell value

LLM Generation Settings

Parameter
Description

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:

  1. Formulate query → LLM generates retrieval query from your Prompt

  2. Retrieve → Fetch relevant rows from Knowledge Table

  3. Rerank → Optional reranking model (RRF Ranker by default)

  4. Inject → Top-k references added to prompt

  5. 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

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 row are 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:

Library
Use Case

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

dtype
Description

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

Error
Solution

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

Current (Use This)
Deprecated (Avoid)

t.MultiRowAddRequest

t.RowAddRequest

t.MultiRowUpdateRequest

t.RowUpdateRequest

t.MultiRowDeleteRequest

t.RowDeleteRequest

jamai.model_ids()

jamai.model_names()


18. COMPLETE EXAMPLE

End-to-end example: Create table, add row, read result, cleanup.


QUICK COPY-PASTE

Last updated

Was this helpful?