open-index/open-npm huggingface dataset:
npm package: @openstack-ai/sdk
Description: Official TypeScript SDK for OpenStack AI - A lightweight client library for chat completions and model management
Author: OpenStack AI
Latest version: 0.1.0

# OpenStack AI SDK

Official TypeScript/JavaScript SDK for [OpenStack AI](https://openstack.ai) - A lightweight, OpenAI-compatible client for chat completions and model management.

[![npm version](https://badge.fury.io/js/@openstack-ai%2Fsdk.svg)](https://www.npmjs.com/package/@openstack-ai/sdk)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Installation

```bash
npm install @openstack-ai/sdk
```

## Quick Start

```typescript
import { Openstack } from '@openstack-ai/sdk';

const openstack = new Openstack(process.env.OPENSTACK_API_KEY);

const response = await openstack.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello!' }]
});

console.log(response.choices[0].message.content);
```

## Examples

### Chat Completion

```typescript
const response = await openstack.chat.completions.create({
  model: 'gpt-4',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'What is the capital of France?' }
  ],
  temperature: 0.7,
  max_tokens: 150
});
```

### Streaming

```typescript
const stream = await openstack.chat.completions.create({
  model: 'gpt-4',
  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

```typescript
const models = await openstack.models.list();
console.log(models.data);
```

### With User Identity

```typescript
const response = await openstack.chat.completions.create(
  {
    model: 'gpt-4',
    messages: [{ role: 'user', content: 'Hello!' }]
  },
  { user: 'user-123' }
);
```

## Features

- **OpenAI-Compatible** - Drop-in replacement with familiar API
- **TypeScript-First** - Full type safety and IntelliSense support
- **Streaming** - Real-time responses with async iterables
- **Lightweight** - Minimal dependencies, ~5KB bundled
- **User Tracking** - Built-in support for user identity and billing

## Documentation

For detailed documentation, guides, and API reference, visit:

**[docs.openstack.ai](https://docs.openstack.ai)**

## Configuration

```typescript
const openstack = new Openstack({
  apiKey: 'your-api-key',
  baseURL: 'https://api.openstack.ai/v1', // optional
  defaultHeaders: { /* optional */ }
});
```

## Error Handling

```typescript
import { OpenstackAPIError } from '@openstack-ai/sdk';

try {
  const response = await openstack.chat.completions.create({...});
} catch (error) {
  if (error instanceof OpenstackAPIError) {
    console.error(error.status, error.message);
  }
}
```

## License

MIT

## Links

- [Documentation](https://docs.openstack.ai)
- [GitHub](https://github.com/openstack-ai/openstack)
- [npm](https://www.npmjs.com/package/@openstack-ai/sdk)
- [Issues](https://github.com/openstack-ai/openstack/issues)