Back to Docs

AI API

AI-powered chat, translation, sentiment, and content generation

Chat

AI conversations

Translate

100+ languages

Sentiment

Emotion analysis

Generate

Content creation

Dual-Key Authentication

API KeyPermanent

X-Smsly-Key-Id: sk_live_xxx

SDK KeyRotatable

X-SMSLY-SDK-KEY: sdk_live_xxx

Quick Start

Python
from smsly import SMSly

# === DUAL KEY SECURITY ===
# Two keys required (both can be in .env or embedded):
# 1. API Key - for authentication
# 2. SDK Key - for SDK validation

client = SMSly(
    api_key="setup_api_your_key",   # From dashboard
    sdk_key="setup_sdk_your_key"    # From dashboard
)

# AI Chat Completion
response = client.ai.chat([
    {"role": "system", "content": "You are a helpful customer support agent."},
    {"role": "user", "content": "How do I track my order?"}
])
print(response.message)

# Summarize customer feedback
summary = client.ai.summarize(
    text="Long customer feedback text here...",
    max_length=100
)
print(summary.text)

# Translate message
translated = client.ai.translate(
    text="Hello, how can I help you?",
    target_lang="es"
)
print(translated.text)  # "Hola, ¿cómo puedo ayudarte?"

# Analyze sentiment
sentiment = client.ai.sentiment("I love your service!")
print(f"Sentiment: {sentiment.label}")  # positive
print(f"Score: {sentiment.score}")  # 0.95

# Generate marketing content
content = client.ai.generate(
    prompt="Write a promotional SMS for a summer sale",
    type="marketing",
    max_length=160
)
print(content.text)

API Endpoints

POST/v1/ai/chatAI chat completion
POST/v1/ai/summarizeSummarize text
POST/v1/ai/translateTranslate text
POST/v1/ai/sentimentAnalyze sentiment
POST/v1/ai/generateGenerate content

Ready to use AI?

Get API Keys