Skip to content

Commit 5578dca

Browse files
committed
logo
1 parent fb5104e commit 5578dca

9 files changed

Lines changed: 311 additions & 155 deletions

File tree

README.md

Lines changed: 95 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Input (messy text) → Output (clean data)
4444

4545
## Quick Example
4646

47+
> **⚠️ API Key Required**: You need an API key to run LangStruct. **[Get one free here →](https://aistudio.google.com/app/apikey)** or see [setup options](#api-key-setup) below.
48+
4749
```python
4850
from langstruct import LangStruct
4951

@@ -85,7 +87,32 @@ print(f"Confidence: {result.confidence:.1%}") # Higher confidence score
8587

8688
## Quick Start
8789

88-
### Installation
90+
### 1. Get an API Key (Required)
91+
92+
**Choose one option:**
93+
94+
<div align="center">
95+
96+
| Provider | Free Tier | Get Key | Best For |
97+
|----------|-----------|---------|----------|
98+
| 🔥 **Google Gemini** | ✅ Yes | **[Get Free Key →](https://aistudio.google.com/app/apikey)** | **Recommended** - Fast & generous free tier |
99+
| OpenAI | ❌ Paid | [Get Key →](https://platform.openai.com/api-keys) | Latest models (GPT-4o, o1) |
100+
| Anthropic | ❌ Paid | [Get Key →](https://console.anthropic.com/) | Claude models |
101+
| Local (Ollama) | ✅ Free | [Install Ollama →](https://ollama.ai/) | Privacy, no API needed |
102+
103+
</div>
104+
105+
**Set your API key:**
106+
```bash
107+
# Recommended: Google Gemini (free)
108+
export GOOGLE_API_KEY="your-key-here"
109+
110+
# Or use others:
111+
export OPENAI_API_KEY="your-key-here"
112+
export ANTHROPIC_API_KEY="your-key-here"
113+
```
114+
115+
### 2. Installation
89116

90117
Until the first public release, install from source:
91118

@@ -121,24 +148,7 @@ pip install langstruct[dev] # Test and lint toolchain
121148
pip install langstruct[all] # Everything above
122149
```
123150

124-
### API Key Setup
125-
126-
**Need an API key?** LangStruct auto-detects whichever providers you configure. Common options:
127-
128-
- [Google Gemini API key](https://aistudio.google.com/app/apikey)
129-
- [OpenAI API key](https://platform.openai.com/api-keys)
130-
- [Anthropic API key](https://console.anthropic.com/)
131-
- [Ollama](https://ollama.ai/) for local models (no API key needed)
132-
133-
```bash
134-
# Set any of these - LangStruct auto-detects the best available model
135-
export GOOGLE_API_KEY="your-key-here" # → Uses gemini-2.5-flash
136-
export OPENAI_API_KEY="your-key-here" # → Uses gpt-5-mini by default (swap to gpt-5-mini/gpt-5-pro via model=)
137-
export ANTHROPIC_API_KEY="your-key-here" # → Uses claude-3-5-haiku-latest by default (upgrade to claude-3-7-sonnet-latest/claude-opus-4-1 via model=)
138-
# Or just install Ollama # → Uses llama3
139-
```
140-
141-
### Basic Usage
151+
### 3. Basic Usage
142152

143153
```python
144154
from langstruct import LangStruct
@@ -352,8 +362,8 @@ for field, spans in result.sources.items():
352362

353363
LangStruct works with any LLM provider:
354364

355-
- **Google Gemini**: gemini/gemini-2.5-flash (recommended - fastest & cheapest), gemini/gemini-2.5-pro
356-
- **OpenAI**: gpt-5-pro, gpt-5-mini, gpt-4o, gpt-4o-mini (current flagships with great speed/quality options)
365+
- **Google Gemini**: gemini/gemini-2.5-flash, gemini/gemini-2.5-pro
366+
- **OpenAI**: gpt-5-pro, gpt-5-mini, gpt-4o, gpt-4o-mini
357367
- **Anthropic**: claude-opus-4-1, claude-sonnet-4-0, claude-3-7-sonnet-latest, claude-3-5-haiku-latest
358368
- **Local**: Any model via Ollama (llama3, mistral, etc.)
359369

@@ -464,12 +474,75 @@ config = ChunkingConfig(
464474

465475
extractor = LangStruct(
466476
schema=YourSchema,
467-
model="gemini/gemini-2.5-flash", # Fast & cost-effective
477+
model="gemini/gemini-2.5-flash",
468478
chunking_config=config,
469479
optimize=True # Enabled for training data
470480
)
471481
```
472482

483+
## 🔧 Troubleshooting
484+
485+
### API Key Issues
486+
487+
**Error: "No API keys found" or "Authentication failed"**
488+
489+
1. **Check your API key is set:**
490+
```bash
491+
echo $GOOGLE_API_KEY # Should show your key
492+
```
493+
494+
2. **Common fixes:**
495+
```bash
496+
# Make sure you're using the right format
497+
export GOOGLE_API_KEY="your-actual-key-here" # No quotes in the key itself
498+
499+
# For persistent setup, add to your shell profile:
500+
echo 'export GOOGLE_API_KEY="your-key"' >> ~/.bashrc
501+
source ~/.bashrc
502+
```
503+
504+
3. **Test your key works:**
505+
```python
506+
import os
507+
print("API key set:", bool(os.getenv("GOOGLE_API_KEY")))
508+
509+
# Quick test
510+
from langstruct import LangStruct
511+
ls = LangStruct(example={"name": "test"})
512+
result = ls.extract("Hello John") # Should work without errors
513+
```
514+
515+
**Error: "Model not found" or "Rate limit exceeded"**
516+
517+
- **Model not found**: Your API key might be for a different provider
518+
- **Rate limits**: Try a different model or wait a few minutes
519+
- **Billing**: Check your account has credits (OpenAI/Anthropic)
520+
521+
### Installation Issues
522+
523+
**Error: Package not found on PyPI**
524+
525+
LangStruct is currently pre-release. Use the source installation:
526+
```bash
527+
git clone https://github.com/langstruct-ai/langstruct.git
528+
cd langstruct
529+
uv sync --extra dev
530+
uv pip install -e .
531+
```
532+
533+
**Import errors or missing dependencies**
534+
535+
```bash
536+
# Reinstall with all dependencies
537+
pip install -e ".[dev,examples,viz,parallel]"
538+
```
539+
540+
### Getting Help
541+
542+
- 🐛 **Bug reports**: [GitHub Issues](https://github.com/langstruct-ai/langstruct/issues)
543+
- 💬 **Questions**: [GitHub Discussions](https://github.com/langstruct-ai/langstruct/discussions)
544+
- 📖 **Documentation**: [langstruct.dev](https://langstruct.dev)
545+
473546
## 🤝 Contributing
474547

475548
We welcome contributions! Please see our [contributing guide](CONTRIBUTING.md) for details.

docs/public/favicon.svg

Lines changed: 30 additions & 5 deletions
Loading

docs/src/assets/hero.svg

Lines changed: 99 additions & 83 deletions
Loading

0 commit comments

Comments
 (0)