Skip to content

internet-court/internet-court-skill / vendored/0g/0g-compute

0g-compute

Verified

0G Compute Network guide for decentralized AI inference, fine-tuning, and GPU services. Covers chatbots, image generation, speech-to-text, SDK integration (0g-serving-broker), processResponse API, broker.inference methods, CLI commands (0g-compute-cli), and account management. Use this skill for any 0G compute, 0G AI, or decentralized GPU question.

references/examples/README.md

View on GitHub
# Complete Examples

Production-ready example projects demonstrating 0G Compute Network integration.

## Available Examples

Choose the example that matches your use case:

### 1. Streaming Chat Application

**File**: [streaming-chat.md](streaming-chat.md)

A complete TypeScript project showcasing **streaming chatbot inference** with real-time output.

**Key Features**:
- ✅ Streaming chat completions with real-time output
- ✅ Automatic balance checking and warnings
- ✅ Proper chatID extraction (headers + stream fallback)
- ✅ Usage tracking and fee management
- ✅ Command-line argument parsing
- ✅ Production-grade error handling

**Best for**: Building conversational AI applications, chatbots, interactive assistants

**What you'll learn**:
- How to handle streaming Server-Sent Events (SSE)
- Correct chatID extraction for chatbot services
- Balance monitoring and fund management
- Real-time response processing

---

### 2. Text-to-Image Generation

**File**: [text-to-image.md](text-to-image.md)

A complete TypeScript project for **generating images from text descriptions** using 0G Compute.

**Key Features**:
- ✅ Image generation from text prompts
- ✅ Batch generation support
- ✅ Image size and quality configuration
- ✅ Result downloading and caching
- ✅ Cost estimation before generation

**Best for**: Image generation tools, creative applications, content creation platforms

**What you'll learn**:
- How to use text-to-image services
- Handling binary image responses
- Cost-effective batch processing
- Image storage and management

---

### 3. Speech-to-Text Transcription

**File**: [speech-to-text.md](speech-to-text.md)

A complete TypeScript project for **transcribing audio files to text** using 0G Compute.

**Key Features**:
- ✅ Audio file transcription (MP3, WAV, OGG, etc.)
- ✅ Multiple format support
- ✅ Timestamp generation
- ✅ Speaker diarization (if supported)
- ✅ Batch processing for multiple files

**Best for**: Transcription services, podcast processing, meeting notes, subtitle generation

**What you'll learn**:
- How to use speech-to-text services
- Handling multipart/form-data uploads
- Audio file format conversion
- Batch transcription workflows

---

## Quick Comparison

| Feature | Streaming Chat | Text-to-Image | Speech-to-Text |
|---------|---------------|---------------|----------------|
| **Service Type** | Chatbot | Text-to-Image | Speech-to-Text |
| **Input** | Text messages | Text prompts | Audio files |
| **Output** | Streaming text | Image URLs/data | Transcribed text |
| **Real-time** | ✅ Yes | ❌ No | ❌ No |
| **File Upload** | ❌ No | ❌ No | ✅ Yes |
| **Batch Support** | ❌ No | ✅ Yes | ✅ Yes |
| **Cost Model** | Per token | Per image | Per second/token |

## Getting Started

1. **Choose your example** based on your use case
2. **Click the link** to view the complete guide
3. **Follow the setup steps** to create your project
4. **Run and customize** the example code

## Prerequisites (All Examples)

Before starting any example, ensure you have:

```bash
# Node.js version check
node --version  # Must be >= 22.0.0

# Install 0G Compute CLI globally
pnpm add @0glabs/0g-serving-broker -g

# Setup network and login
0g-compute-cli setup-network
0g-compute-cli login

# Deposit funds
0g-compute-cli deposit --amount 10
```

## Common Setup Steps

All examples follow a similar structure:

1. **Project initialization**: Create directory, install dependencies
2. **Environment configuration**: Setup `.env` file with private key
3. **Account management**: Deposit funds and transfer to providers
4. **Provider acknowledgment**: Acknowledge provider before first use
5. **Run the example**: Execute and test the application

## Finding Providers

To list available providers for each service type:

```bash
# List all providers
0g-compute-cli inference list-providers

# Filter by service type in the output
```

**Service Type Identifiers**:
- `chatbot` - Conversational AI services
- `text-to-image` - Image generation services
- `speech-to-text` - Audio transcription services

## Additional Resources

- **API Reference**: See [inference.md](../inference.md) for detailed API documentation
- **Account Management**: See [account-management.md](../account-management.md) for fund management
- **SDK Documentation**: See [SKILL.md](../../SKILL.md) for quick SDK reference

## Contributing Examples

Have a useful integration pattern? Consider contributing:

1. Follow the existing example structure
2. Include complete setup instructions
3. Add production-ready error handling
4. Document all API calls and parameters
5. Test on both testnet and mainnet

## Next Steps

After completing these examples, explore:

- **Fine-tuning**: [fine-tuning.md](../fine-tuning.md) - Train custom models
- **Advanced Patterns**: Combine multiple services in one application
- **Production Deployment**: Scale your application with load balancing
- **Monitoring**: Add logging and metrics for production use
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall