Once a chat is created, it will assume the paradigms that it is created with. Sending chats different paradigm configurations will lead to issues.
Official SDKs
We provide official SDKs for Python and JavaScript/TypeScript to make integration easier.
Python SDK
Install via pip:
PyPI Package: https://pypi.org/project/textql/
Basic Setup
from textql import TextQLClient
# Initialize the client
client = TextQLClient(api_key="YOUR_API_KEY")
tools = {
"connector_ids": [509, 493], # Database connectors to use
"web_search_enabled": True, # Enable web search
"sql_enabled": True, # Enable SQL queries <- Need if you are using sql connector
"python_enabled": True, # Enable Python execution
"ontology_enabled": False, # Enable ontology queries
"tableau_enabled": False, # Enable Tableau integration
"powerbi_enabled": False, # Enable PowerBI integration
"google_drive_enabled": False, # Enable Google Drive access
}
Streaming Endpoint
# Stream a chat conversation
stream = client.chat.stream(
question="Tell me about the connected datasource",
chat_id="existing-chat-id", # Optional: continue existing chat
tools=tools
)
for response in stream:
if response.HasField('text'):
print(response.text, end='', flush=True)
elif response.HasField('metadata'):
print(f"\nChat ID: {response.metadata.chat_id}")
elif response.HasField('preview'):
print(f"\nPreview: {response.preview.url}") # <- Hosted S3 image
One-Shot Endpoint
# Execute a single chat query
response = client.chat.send(
question="What is the color of the sky?",
chat_id="existing-chat-id", # Optional: continue existing chat
tools=tools
)
print(response.text)
JavaScript/TypeScript SDK
Install via npm:
NPM Package: https://www.npmjs.com/package/@textql/sdk
Basic Setup
import { createTextQLClient } from '@textql/sdk';
// Initialize the client
const client = new createTextQLClient({ apiKey: 'YOUR_API_KEY' });
const tools = {
connectorIds: [513, 514], // Database connectors to use
webSearchEnabled: true, // Enable web search
sqlEnabled: true, // Enable SQL queries <- Need if you are using sql connector
pythonEnabled: true, // Enable Python execution
ontologyEnabled: false, // Enable ontology queries
tableauEnabled: false, // Enable Tableau integration
powerbiEnabled: false, // Enable PowerBI integration
googleDriveEnabled: false, // Enable Google Drive access
};
Streaming Endpoint
// Stream a chat conversation
const stream = client.chat.stream({
question: "Draw me a picture of the sky, query the connected db. Make the image of the sky reflect the data stored",
tools: tools
});
for await (const message of stream) {
const { case: messageCase, value } = message.message;
switch (messageCase) {
case 'text':
process.stdout.write(value);
break;
case 'metadata':
console.log(`\nChat ID: ${value.chatId}`);
break;
case 'preview':
console.log(`\nPreview URL: ${value.url}`);
break;
default:
console.log(`\nUnknown message type: ${messageCase}`);
break;
}
}
One-Shot Endpoint
// Execute a single chat query
const response = await client.chat.send({
question: 'What is the color of the sky?',
chatId: 'existing-chat-id', // Optional: continue existing chat
tools: tools
});
console.log(response.text);
Getting Your API Key
You can get your API key if you are an admin in:
https://app.textql.com/settings → Configuration → API Keys