Get up and running with the OneApp API in under 5 minutes.
# Install the SDK
npm install @oneapp/sdk
# Or with yarn
yarn add @oneapp/sdk
# Or with pnpm
pnpm add @oneapp/sdkGet your API key from the Dashboard and configure the client.
import { OneApp } from '@oneapp/sdk';
// Initialize the client
const oneapp = new OneApp({
apiKey: process.env.ONEAPP_API_KEY,
});
// Get current user
const user = await oneapp.auth.getCurrentUser();
console.log('Hello,', user.name);Create an AI conversation:
import { OneApp } from '@oneapp/sdk';
const oneapp = new OneApp({
apiKey: process.env.ONEAPP_API_KEY,
});
// Create a conversation
const conversation = await oneapp.ai.conversations.create({
title: 'My First Conversation',
model: 'claude-3-opus',
});
console.log('Created conversation:', conversation.id);Chat with AI:
// Send a message and get AI response
const response = await oneapp.ai.messages.create({
conversationId: conversation.id,
role: 'user',
content: 'Hello! Can you help me with Python?',
});
console.log('AI Response:', response.assistantMessage.content);Explore more features: