[package]
name = "rstructor"
version = "0.3.2"
edition = "2024"
description = "Get structured, validated data out of LLMs as native Rust structs and enums. Derive a type and rstructor generates the JSON Schema, prompts the model, parses the reply, and retries on validation errors — across OpenAI, Anthropic Claude, Google Gemini, and xAI Grok. The Rust answer to Python's Pydantic + Instructor."
license = "MIT"
repository = "https://github.com/clifton/rstructor"
authors = ["Clifton King <cliftonk@gmail.com>"]
readme = "README.md"
documentation = "https://docs.rs/rstructor"
exclude = [
"release.sh",
"*.sh",
"CLAUDE.md",
"EXAMPLES.md",
".github/",
".gitignore",
".gitattributes",
".claude/",
"tmp/",
"*.orig",
"*.bak",
]
keywords = ["llm", "structured-output", "json-schema", "openai", "anthropic"]
categories = [
"api-bindings",
"science",
"parsing",
"text-processing",
"asynchronous",
]
[dependencies]
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
async-trait = "0.1.89"
tokio = { version = "1.52.1", features = [
"rt",
"macros",
"rt-multi-thread",
"io-std",
], optional = true }
reqwest = { version = "0.13.3", features = [
"json",
"query",
"default-tls",
], default-features = false, optional = true }
thiserror = "2.0.18"
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = [
"env-filter",
], optional = true }
tracing-futures = { version = "0.2.5", optional = true }
rstructor_derive = { version = "0.3.2", path = "./rstructor_derive", optional = true }
base64 = { version = "0.22.1", optional = true }
futures-util = { version = "0.3.31", default-features = false, optional = true }
async-stream = { version = "0.3.6", optional = true }
[features]
default = ["openai", "anthropic", "grok", "gemini", "derive", "logging"]
openai = ["_client"]
anthropic = ["_client"]
grok = ["_client"]
gemini = ["_client"]
derive = ["rstructor_derive"]
logging = ["tracing-subscriber", "tracing-futures"]
_client = ["reqwest", "tokio", "base64"]
streaming = ["_client", "reqwest/stream", "futures-util", "async-stream"]
tools = ["_client"]
mock = []
[[example]]
name = "streaming_example"
required-features = ["streaming"]
[[example]]
name = "tool_calling_example"
required-features = ["tools", "openai"]
[[example]]
name = "mock_testing_example"
required-features = ["mock"]
[dev-dependencies]
chrono = { version = "0.4.44", features = ["serde"] }
tokio = { version = "1.52.1", features = ["rt", "macros", "rt-multi-thread"] }
mockito = "1.7.0"
[workspace]
members = ["rstructor_derive"]