Loading...
Loading...
Official SDKs for TypeScript, Python, and Go. Drop-in compatible with the OpenAI SDK — just change the base URL.
OpenAI SDK compatible. If you already use the OpenAI SDK, you can use Aisays.ai without installing a new SDK. Just set baseURL to https://api.aisays.ai/v1.
Full-featured TypeScript SDK with streaming, auto-retry, and type-safe responses.
Setup
import { AisaysAI } from "aisaysai"
const client = new AisaysAI({
apiKey: process.env.AISAYSAI_API_KEY,
// Optional: base URL, timeout, retry config
})Usage Examples
// Chat completion
const response = await client.chat.completions.create({
model: "deepseek/deepseek-v4-flash",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Hello!" },
],
max_tokens: 500,
})
console.log(response.choices[0].message.content)
// Streaming
const stream = await client.chat.completions.create({
model: "moonshot/kimi-k2.5",
messages: [{ role: "user", content: "Tell me a story" }],
stream: true,
})
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content || "")
}
// List models
const models = await client.models.list()
models.data.forEach((m) => console.log(m.id))Python SDK with async support, type hints, and OpenAI-compatible drop-in.
Setup
from aisaysai import AisaysAI
client = AisaysAI(
api_key="sk-or-YOUR_API_KEY",
# Optional: base_url, timeout, max_retries
)Usage Examples
# Chat completion
response = client.chat.completions.create(
model="deepseek/deepseek-v4-flash",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"},
],
max_tokens=500,
)
print(response.choices[0].message.content)
# Streaming
stream = client.chat.completions.create(
model="moonshot/kimi-k2.5",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
# Async
import asyncio
from aisaysai import AsyncAisaysAI
async_client = AsyncAisaysAI(api_key="sk-or-YOUR_API_KEY")
async def main():
response = await async_client.chat.completions.create(
model="deepseek/deepseek-v4-flash",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
asyncio.run(main())Go SDK with context support, structured logging, and connection pooling.
Setup
package main
import (
"context"
"github.com/aisaysai/aisaysai-go"
)
func main() {
client := aisaysai.NewClient(
aisaysai.WithAPIKey("sk-or-YOUR_API_KEY"),
)
_ = client
}Usage Examples
// Chat completion
ctx := context.Background()
resp, err := client.Chat.Completions.Create(ctx, aisaysai.ChatCompletionRequest{
Model: "deepseek/deepseek-v4-flash",
Messages: []aisaysai.Message{
{Role: "system", Content: "You are a helpful assistant."},
{Role: "user", Content: "Hello!"},
},
MaxTokens: 500,
})
if err != nil {
log.Fatal(err)
}
fmt.Println(resp.Choices[0].Message.Content)
// Streaming
stream, err := client.Chat.Completions.CreateStreaming(ctx, aisaysai.ChatCompletionRequest{
Model: "moonshot/kimi-k2.5",
Messages: []aisaysai.Message{
{Role: "user", Content: "Tell me a story"},
},
})
if err != nil {
log.Fatal(err)
}
defer stream.Close()
for stream.Next() {
chunk := stream.Current()
fmt.Print(chunk.Choices[0].Delta.Content)
}Prefer raw HTTP? All endpoints are documented with OpenAPI specs.