Skip to content
ainzowlPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

clore-js

Unofficial JavaScript/TypeScript SDK for Clore.ai GPU marketplace.

Rent powerful GPUs for AI/ML workloads with a simple, promise-based interface. Works with both JavaScript and TypeScript. Zero runtime dependencies.

Install

npm install clore-js

Node.js Quickstart

const { CloreAI } = require('clore-js');

// Set CLORE_API_KEY env var, or pass api_key directly
const client = new CloreAI();

// Browse available GPUs
const servers = await client.marketplace({ gpu: 'RTX 4090', max_price_usd: 5.0 });
for (const s of servers) {
  console.log(`${s.gpu_model} — $${s.price_usd}/day — ${s.location}`);
}

// Rent a server
await client.create_order({
  server_id: servers[0].id,
  image: 'cloreai/ubuntu22.04-cuda12',
  type: 'on-demand',
  currency: 'bitcoin',
  ssh_password: 'MyPass123',
  ports: { '22': 'tcp', '8888': 'http' },
});

// Check your orders
const orders = await client.my_orders();
console.log(orders);

ESM

import { CloreAI } from 'clore-js';

const client = new CloreAI({ api_key: 'your_key' });
const wallets = await client.wallets();
console.log(wallets);

TypeScript

import { CloreAI, type MarketplaceServer } from 'clore-js';

const client = new CloreAI();
const servers: MarketplaceServer[] = await client.marketplace({ gpu: 'A100' });

Authentication

API key resolution (checked in order):

  1. api_key constructor option
  2. CLORE_API_KEY environment variable
  3. ~/.clore/config.json file ({"api_key": "..."})
export CLORE_API_KEY=your_api_key_here

API

Constructor

const client = new CloreAI({
  api_key: 'your_key',                    // optional if env/config set
  base_url: 'https://api.clore.ai/v1',   // default
  timeout: 30000,                          // ms, default 30s
  max_retries: 3,                          // default 3
});

Methods

Method Auth Returns Description
wallets() Yes Wallet[] Wallet balances and deposit addresses
marketplace(filters?) No MarketplaceServer[] Browse available GPU servers
my_servers() Yes MyServer[] Your hosted servers
server_config(name) Yes ServerConfig Detailed server configuration
my_orders(include_completed?) Yes Order[] Your rental orders
create_order(params) Yes APIResponse Create a rental order
cancel_order(order_id, issue?) Yes APIResponse Cancel an order
spot_marketplace(server_id) Yes SpotMarket Spot market offers for a server
set_spot_price(order_id, price) Yes APIResponse Update your spot bid price
set_server_settings(params) Yes APIResponse Update server marketplace settings

Examples

Browse Marketplace

// No API key needed for marketplace
const client = new CloreAI({ api_key: null });

const servers = await client.marketplace({
  gpu: 'RTX 4090',
  min_gpu_count: 2,
  min_ram_gb: 64,
  max_price_usd: 3.0,
  available_only: true,  // default
});

for (const s of servers) {
  console.log(`${s.id}: ${s.gpu_model} x${s.gpu_count} — ${s.ram_gb}GB RAM — $${s.price_usd}/day`);
}

Create an Order

const result = await client.create_order({
  server_id: 123,
  image: 'cloreai/ubuntu22.04-cuda12',
  type: 'on-demand',       // or 'spot'
  currency: 'bitcoin',
  ssh_password: 'MyPass123',
  ports: { '22': 'tcp', '8888': 'http' },
  env: { MODEL: 'llama3' },
  command: 'bash /root/start.sh',
});
// result.code === 0 on success

Spot Orders

// Create a spot bid
await client.create_order({
  server_id: 456,
  image: 'cloreai/pytorch',
  type: 'spot',
  currency: 'bitcoin',
  spot_price: 0.0001,
});

// View spot market
const spot = await client.spot_marketplace(456);
for (const offer of spot.offers ?? []) {
  console.log(`Offer ${offer.order_id}: ${offer.price} BTC/day`);
}

// Lower your spot price
await client.set_spot_price(39, 0.000003);

Wallets

const wallets = await client.wallets();
for (const w of wallets) {
  console.log(`${w.name}: ${w.balance} (deposit: ${w.deposit})`);
}

Server Management

const myServers = await client.my_servers();
for (const srv of myServers) {
  console.log(`${srv.name} (${srv.gpu_model}) — ${srv.status}`);
}

const config = await client.server_config('MyGPU');
console.log(`On-demand: $${config.on_demand_price}/day, Spot: $${config.spot_price}/day`);

await client.set_server_settings({
  name: 'MyGPU',
  availability: true,
  mrl: 96,
  on_demand: 0.0001,
  spot: 0.00000113,
});

Cancel an Order

await client.cancel_order(38, 'no longer needed');

Error Handling

const { CloreAI, AuthError, RateLimitError, CloreAPIError } = require('clore-js');

try {
  const wallets = await client.wallets();
} catch (err) {
  if (err instanceof AuthError) {
    console.error('Invalid API key');
  } else if (err instanceof RateLimitError) {
    console.error('Rate limited — SDK retries automatically, this means retries exhausted');
  } else if (err instanceof CloreAPIError) {
    console.error(`API error [${err.code}]: ${err.message}`);
  }
}
Code Class Meaning
1 DBError Database error
2 InvalidInputError Invalid input data
3 AuthError Invalid API token
4 InvalidEndpointError Invalid endpoint
5 RateLimitError Rate limit exceeded
6 FieldError Field-specific error

Rate Limiting

Built-in, no configuration needed:

  • 1 request/second for all endpoints
  • 5 second cooldown for create_order()
  • Automatic retry with exponential backoff on rate limit (code 5) and server errors (5xx)

Python SDK Compatibility

AsyncCloreAI is exported as an alias for CloreAI. Same methods, same signatures — drop-in replacement for the Python SDK in JS environments.

const { AsyncCloreAI } = require('clore-js');
const client = new AsyncCloreAI();

Development

git clone https://github.com/AinzOwl/clore-js.git
cd clore-js
npm install
npm run build        # ESM + CJS + types
npm test             # unit tests
npm run test:live    # live API tests (needs CLORE_API_KEY)
npm run typecheck    # TypeScript check

Links


MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages