FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Outlines Has a Free API: Guarantee Valid JSON Output From Any LLM
How-ToProgramming Languages

Outlines Has a Free API: Guarantee Valid JSON Output From Any LLM

via Dev.to PythonAlex Spinov2h ago

LLMs sometimes return invalid JSON. Outlines makes it physically impossible — by constraining token generation to match your schema. What Is Outlines? Outlines is a Python library that constrains LLM text generation using formal grammars. Unlike Instructor (which validates after generation), Outlines constrains DURING generation — the LLM can only produce valid tokens. import outlines model = outlines . models . transformers ( " mistralai/Mistral-7B-v0.3 " ) # JSON schema constraint schema = ''' { " type " : " object " , " properties " : { " name " : { " type " : " string " }, " age " : { " type " : " integer " }, " city " : { " type " : " string " } }, " required " : [ " name " , " age " , " city " ] } ''' generator = outlines . generate . json ( model , schema ) result = generator ( " Extract info: John is 30 and lives in NYC " ) # GUARANTEED valid JSON matching schema # {"name": "John", "age": 30, "city": "NYC"} Regex Constraints # Phone number — only valid phone patterns phone_gen

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
0 views

Related Articles

How-To

How to implement the Outbox pattern in Go and Postgres

Lobsters • 21m ago

The Hidden Algorithm Behind Google Maps Traffic!!!!
How-To

The Hidden Algorithm Behind Google Maps Traffic!!!!

Medium Programming • 28m ago

Percentage Change: The Most Misused Metric in Data Analysis (And How to Calculate It Correctly)
How-To

Percentage Change: The Most Misused Metric in Data Analysis (And How to Calculate It Correctly)

Medium Programming • 5h ago

I Missed This Claude Setting at First. And It Actually Matters
How-To

I Missed This Claude Setting at First. And It Actually Matters

Medium Programming • 6h ago

Instacart Promo Code: Save on Groceries in March 2026
How-To

Instacart Promo Code: Save on Groceries in March 2026

Wired • 8h ago

Discover More Articles