open-index/open-npm huggingface dataset:
npm package: @odysseyml/odyssey
Description: JavaScript/TypeScript client for Odyssey's audio-visual intelligence platform
Author: Odyssey Team
Latest version: 1.2.0

# @odysseyml/odyssey

JavaScript/TypeScript client for Odyssey's audio-visual intelligence platform.

## Install

```bash
npm install @odysseyml/odyssey
```

## Quick Start

```typescript
import { Odyssey } from '@odysseyml/odyssey';

const client = new Odyssey({ apiKey: 'your_api_key' });

try {
  const stream = await client.connect({
    onConnected: (stream) => {
      document.querySelector('video')!.srcObject = stream;
    }
  });

  await client.startStream({ prompt: 'A cat' });
  await client.interact({ prompt: 'Pet the cat' });
  await client.endStream();
} catch (err) {
  console.error('Connection failed:', err);
} finally {
  client.disconnect();
}
```

## React

```tsx
import { useOdyssey } from '@odysseyml/odyssey/react';
import { useEffect, useRef } from 'react';

function App() {
  const videoRef = useRef<HTMLVideoElement>(null);

  const odyssey = useOdyssey({
    apiKey: 'your_api_key',
    handlers: {
      onConnected: (stream) => {
        if (videoRef.current) videoRef.current.srcObject = stream;
      }
    }
  });

  useEffect(() => {
    odyssey.connect().catch(err => {
      console.error('Connection failed:', err.message);
    });
    return () => odyssey.disconnect();
  }, []);

  return (
    <div>
      <video ref={videoRef} autoPlay playsInline muted />
      <button onClick={() => odyssey.startStream({ prompt: 'A forest' })}>Start</button>
      <button onClick={() => odyssey.interact({ prompt: 'Look around' })}>Interact</button>
      <button onClick={() => odyssey.endStream()}>End</button>
    </div>
  );
}
```

## Spectator Playback

Connect to a broadcast stream as a spectator using WHEP:

```typescript
import { Odyssey } from '@odysseyml/odyssey';

// Get webrtcUrl and spectatorToken from onBroadcastReady callback
const connection = await Odyssey.connectToStream(webrtcUrl, spectatorToken);

// Attach to video element
document.querySelector('video').srcObject = connection.stream;

// Later, disconnect
connection.disconnect();
```

## Requirements

- **Browser**: Chrome/Edge 90+, Firefox 88+, Safari 14.1+ (requires WebRTC)
- **Node.js**: 18.0.0+ (requires `ws` package)

## Links

- [API Reference](https://documentation.api.odyssey.ml/)
- [Get an API key](https://documentation.api.odyssey.ml/)