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

Installation Guide

📘

JavaScript/TypeScript

Installation

npm
npm install @onelastai/sdk

or with yarn:

yarn
yarn add @onelastai/sdk

Basic Usage

javascript
1import { OnelastAI } from '@onelastai/sdk';
2
3const client = new OnelastAI({
4 apiKey: process.env.ONELASTAI_API_KEY
5});
6
7// Get all agents
8const agents = await client.agents.list();
9
10// Send a message to an agent
11const response = await client.conversations.send({
12 agentId: 'agent_123',
13 message: 'Hello, how are you?'
14});
15
16console.log(response.reply);

Creating an Agent

javascript
1const 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
8console.log(newAgent.id);
🐍

Python

Installation

pip
pip install onelastai-sdk

Basic Usage

python
1from onelastai import OnelastAI
2
3client = OnelastAI(api_key='YOUR_API_KEY')
4
5# Get all agents
6agents = client.agents.list()
7
8# Send a message
9response = client.conversations.send(
10 agent_id='agent_123',
11 message='Hello, how are you?'
12)
13
14print(response['reply'])

Async Support

python
1import asyncio
2from onelastai import AsyncOnelastAI
3
4async 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
14asyncio.run(main())
🐹

Go

Installation

go get
go get github.com/onelastai/sdk-go

Basic Usage

go
1package main
2
3import (
4 "fmt"
5 "github.com/onelastai/sdk-go"
6)
7
8func 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-php

Basic Usage

php
1<?php
2require 'vendor/autoload.php';
3
4use 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
19echo $response['reply'];
20?>
💎

Ruby

Installation

gem
gem install onelastai-sdk

Basic Usage

ruby
1require 'onelastai'
2
3client = OnelastAI::Client.new(api_key: ENV['ONELASTAI_API_KEY'])
4
5# List agents
6agents = client.agents.list
7
8# Send message
9response = client.conversations.send(
10 agent_id: 'agent_123',
11 message: 'Hello!'
12)
13
14puts 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
1import com.onelastai.sdk.OnelastAI;
2import com.onelastai.sdk.models.Agent;
3
4public 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

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