SDKs & Libraries
Official SDKs for popular programming languages. Simplify your integration with our well-documented, production-ready libraries.
⚙️
Easy to Use
Simple APIs that make it easy to integrate One Last AI into your apps
📦
Well-Maintained
Regularly updated with bug fixes and new features
📚
Fully Documented
Comprehensive documentation with examples for every feature
Available SDKs
📘
v2.0.0JavaScript/TypeScript
Modern SDK for Node.js and browser environments
Learn more →🐍
v1.8.0Python
Complete Python SDK with async support
Learn more →🐹
v1.5.0Go
High-performance Go SDK for enterprise applications
Learn more →🚀
v2.1.0PHP
Full-featured PHP SDK for web applications
Learn more →💎
v1.3.0Ruby
Ruby gem for seamless integration
Learn more →☕
v2.2.0Java
Enterprise-grade Java SDK
Learn more →Installation Guide
📘
JavaScript/TypeScript
Installation
npm
npm install @onelastai/sdkor with yarn:
yarn
yarn add @onelastai/sdkBasic Usage
javascript
| 1 | import { OnelastAI } from '@onelastai/sdk'; |
| 2 | |
| 3 | const client = new OnelastAI({ |
| 4 | apiKey: process.env.ONELASTAI_API_KEY |
| 5 | }); |
| 6 | |
| 7 | // Get all agents |
| 8 | const agents = await client.agents.list(); |
| 9 | |
| 10 | // Send a message to an agent |
| 11 | const response = await client.conversations.send({ |
| 12 | agentId: 'agent_123', |
| 13 | message: 'Hello, how are you?' |
| 14 | }); |
| 15 | |
| 16 | console.log(response.reply); |
Creating an Agent
javascript
| 1 | const newAgent = await client.agents.create({ |
| 2 | name: 'My Bot', |
| 3 | personality: 'helpful', |
| 4 | model: 'gpt-4', |
| 5 | systemPrompt: 'You are a helpful assistant' |
| 6 | }); |
| 7 | |
| 8 | console.log(newAgent.id); |
🐍
Python
Installation
pip
pip install onelastai-sdkBasic Usage
python
| 1 | from onelastai import OnelastAI |
| 2 | |
| 3 | client = OnelastAI(api_key='YOUR_API_KEY') |
| 4 | |
| 5 | # Get all agents |
| 6 | agents = client.agents.list() |
| 7 | |
| 8 | # Send a message |
| 9 | response = client.conversations.send( |
| 10 | agent_id='agent_123', |
| 11 | message='Hello, how are you?' |
| 12 | ) |
| 13 | |
| 14 | print(response['reply']) |
Async Support
python
| 1 | import asyncio |
| 2 | from onelastai import AsyncOnelastAI |
| 3 | |
| 4 | async def main(): |
| 5 | client = AsyncOnelastAI(api_key='YOUR_API_KEY') |
| 6 | |
| 7 | response = await client.conversations.send( |
| 8 | agent_id='agent_123', |
| 9 | message='Hello!' |
| 10 | ) |
| 11 | |
| 12 | print(response['reply']) |
| 13 | |
| 14 | asyncio.run(main()) |
🐹
Go
Installation
go get
go get github.com/onelastai/sdk-goBasic Usage
go
| 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "github.com/onelastai/sdk-go" |
| 6 | ) |
| 7 | |
| 8 | func main() { |
| 9 | client := onelastai.NewClient("YOUR_API_KEY") |
| 10 | |
| 11 | // List agents |
| 12 | agents, err := client.Agents.List() |
| 13 | if err != nil { |
| 14 | panic(err) |
| 15 | } |
| 16 | |
| 17 | // Send message |
| 18 | response, err := client.Conversations.Send(&onelastai.Message{ |
| 19 | AgentID: "agent_123", |
| 20 | Text: "Hello!", |
| 21 | }) |
| 22 | |
| 23 | fmt.Println(response.Reply) |
| 24 | } |
🚀
PHP
Installation
composer
composer require onelastai/sdk-phpBasic Usage
php
| 1 | <?php |
| 2 | require 'vendor/autoload.php'; |
| 3 | |
| 4 | use OnelastAI\Client; |
| 5 | |
| 6 | $client = new Client([ |
| 7 | 'api_key' => 'YOUR_API_KEY' |
| 8 | ]); |
| 9 | |
| 10 | // List agents |
| 11 | $agents = $client->agents->list(); |
| 12 | |
| 13 | // Send message |
| 14 | $response = $client->conversations->send([ |
| 15 | 'agent_id' => 'agent_123', |
| 16 | 'message' => 'Hello!' |
| 17 | ]); |
| 18 | |
| 19 | echo $response['reply']; |
| 20 | ?> |
💎
Ruby
Installation
gem
gem install onelastai-sdkBasic Usage
ruby
| 1 | require 'onelastai' |
| 2 | |
| 3 | client = OnelastAI::Client.new(api_key: ENV['ONELASTAI_API_KEY']) |
| 4 | |
| 5 | # List agents |
| 6 | agents = client.agents.list |
| 7 | |
| 8 | # Send message |
| 9 | response = client.conversations.send( |
| 10 | agent_id: 'agent_123', |
| 11 | message: 'Hello!' |
| 12 | ) |
| 13 | |
| 14 | puts response['reply'] |
☕
Java
Installation
Add to your pom.xml:
pom.xml
<dependency>
<groupId>com.onelastai</groupId>
<artifactId>sdk-java</artifactId>
<version>2.2.0</version>
</dependency>Basic Usage
java
| 1 | import com.onelastai.sdk.OnelastAI; |
| 2 | import com.onelastai.sdk.models.Agent; |
| 3 | |
| 4 | public class Main { |
| 5 | public static void main(String[] args) { |
| 6 | OnelastAI client = new OnelastAI("YOUR_API_KEY"); |
| 7 | |
| 8 | // List agents |
| 9 | List<Agent> agents = client.agents().list(); |
| 10 | |
| 11 | // Send message |
| 12 | String response = client.conversations() |
| 13 | .send("agent_123", "Hello!"); |
| 14 | |
| 15 | System.out.println(response); |
| 16 | } |
| 17 | } |
SDK Feature Comparison
| Feature | JavaScript | Python | Go | PHP |
|---|---|---|---|---|
| RESTful API Support | ✓ | ✓ | ✓ | ✓ |
| Real-time Streaming | ✓ | ✓ | ✓ | ✗ |
| File Upload | ✓ | ✓ | ✓ | ✓ |
| Error Handling | ✓ | ✓ | ✓ | ✓ |
| Type Safety | ✓ | ✗ | ✓ | ✗ |
| Async/Await | ✓ | ✓ | ✓ | ✗ |
| WebSocket Support | ✓ | ✓ | ✓ | ✗ |
| Rate Limiting | ✓ | ✓ | ✓ | ✓ |
Common Patterns
Error Handling
javascript
try {
const response = await client
.conversations.send({...});
} catch (error) {
if (error.code === 'RATE_LIMITED') {
// Handle rate limit
} else if (error.code === 'AUTH_ERROR') {
// Handle auth error
} else {
// Handle other errors
}
}Retry Logic
javascript
const maxRetries = 3;
let attempt = 0;
while (attempt < maxRetries) {
try {
return await client.agents.list();
} catch (error) {
attempt++;
await sleep(Math.pow(2, attempt) * 1000);
}
}Pagination
javascript
const agents = [];
let page = 1;
while (true) {
const result = await client
.agents.list({
page: page,
limit: 50
});
agents.push(...result.data);
if (!result.hasMore) break;
page++;
}Streaming Responses
javascript
const stream = await client
.conversations.stream({
agentId: 'agent_123',
message: 'Write a poem'
});
for await (const chunk of stream) {
process.stdout.write(chunk.data);
}Ready to Start Coding?
Choose your SDK, follow the installation guide, and start building powerful AI agent applications today.