[package]
edition = "2024"
name = "rstructor"
version = "0.3.2"
authors = ["Clifton King <cliftonk@gmail.com>"]
build = false
exclude = [
"release.sh",
"*.sh",
"CLAUDE.md",
"EXAMPLES.md",
".github/",
".gitignore",
".gitattributes",
".claude/",
"tmp/",
"*.orig",
"*.bak",
]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
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."
documentation = "https://docs.rs/rstructor"
readme = "README.md"
keywords = [
"llm",
"structured-output",
"json-schema",
"openai",
"anthropic",
]
categories = [
"api-bindings",
"science",
"parsing",
"text-processing",
"asynchronous",
]
license = "MIT"
repository = "https://github.com/clifton/rstructor"
[features]
_client = [
"reqwest",
"tokio",
"base64",
]
anthropic = ["_client"]
default = [
"openai",
"anthropic",
"grok",
"gemini",
"derive",
"logging",
]
derive = ["rstructor_derive"]
gemini = ["_client"]
grok = ["_client"]
logging = [
"tracing-subscriber",
"tracing-futures",
]
mock = []
openai = ["_client"]
streaming = [
"_client",
"reqwest/stream",
"futures-util",
"async-stream",
]
tools = ["_client"]
[lib]
name = "rstructor"
path = "src/lib.rs"
[[example]]
name = "anthropic_multimodal_example"
path = "examples/anthropic_multimodal_example.rs"
[[example]]
name = "container_attributes_example"
path = "examples/container_attributes_example.rs"
[[example]]
name = "custom_type_example"
path = "examples/custom_type_example.rs"
[[example]]
name = "enum_example"
path = "examples/enum_example.rs"
[[example]]
name = "enum_with_data_example"
path = "examples/enum_with_data_example.rs"
[[example]]
name = "event_planner"
path = "examples/event_planner.rs"
[[example]]
name = "gemini_multimodal_example"
path = "examples/gemini_multimodal_example.rs"
[[example]]
name = "grok_multimodal_example"
path = "examples/grok_multimodal_example.rs"
[[example]]
name = "logging_example"
path = "examples/logging_example.rs"
[[example]]
name = "manual_implementation"
path = "examples/manual_implementation.rs"
[[example]]
name = "medical_example"
path = "examples/medical_example.rs"
[[example]]
name = "mock_testing_example"
path = "examples/mock_testing_example.rs"
required-features = ["mock"]
[[example]]
name = "movie_example"
path = "examples/movie_example.rs"
[[example]]
name = "nested_enum_example"
path = "examples/nested_enum_example.rs"
[[example]]
name = "nested_objects_example"
path = "examples/nested_objects_example.rs"
[[example]]
name = "news_article_categorizer"
path = "examples/news_article_categorizer.rs"
[[example]]
name = "openai_multimodal_example"
path = "examples/openai_multimodal_example.rs"
[[example]]
name = "serde_rename_example"
path = "examples/serde_rename_example.rs"
[[example]]
name = "streaming_example"
path = "examples/streaming_example.rs"
required-features = ["streaming"]
[[example]]
name = "structured_movie_info"
path = "examples/structured_movie_info.rs"
[[example]]
name = "token_usage_example"
path = "examples/token_usage_example.rs"
[[example]]
name = "tool_calling_example"
path = "examples/tool_calling_example.rs"
required-features = [
"tools",
"openai",
]
[[example]]
name = "validation_example"
path = "examples/validation_example.rs"
[[example]]
name = "weather_example"
path = "examples/weather_example.rs"
[[test]]
name = "anthropic_multimodal_tests"
path = "tests/anthropic_multimodal_tests.rs"
[[test]]
name = "anyclient_env_tests"
path = "tests/anyclient_env_tests.rs"
[[test]]
name = "complex_enum_integration_tests"
path = "tests/complex_enum_integration_tests.rs"
[[test]]
name = "container_attributes_tests"
path = "tests/container_attributes_tests.rs"
[[test]]
name = "container_description_tests"
path = "tests/container_description_tests.rs"
[[test]]
name = "conversation_history_tests"
path = "tests/conversation_history_tests.rs"
[[test]]
name = "core_ergonomics_test"
path = "tests/core_ergonomics_test.rs"
[[test]]
name = "custom_type_schema_tests"
path = "tests/custom_type_schema_tests.rs"
[[test]]
name = "derive_macro_tests"
path = "tests/derive_macro_tests.rs"
[[test]]
name = "derive_rename_enum_tests"
path = "tests/derive_rename_enum_tests.rs"
[[test]]
name = "derive_schema_offline_tests"
path = "tests/derive_schema_offline_tests.rs"
[[test]]
name = "error_tests"
path = "tests/error_tests.rs"
[[test]]
name = "example_validation_tests"
path = "tests/example_validation_tests.rs"
[[test]]
name = "gemini_multimodal_tests"
path = "tests/gemini_multimodal_tests.rs"
[[test]]
name = "grok_multimodal_tests"
path = "tests/grok_multimodal_tests.rs"
[[test]]
name = "hashmap_integration_tests"
path = "tests/hashmap_integration_tests.rs"
[[test]]
name = "http_mock_tests"
path = "tests/http_mock_tests.rs"
[[test]]
name = "instructor_tests"
path = "tests/instructor_tests.rs"
[[test]]
name = "integration_tests"
path = "tests/integration_tests.rs"
[[test]]
name = "llm_integration_tests"
path = "tests/llm_integration_tests.rs"
[[test]]
name = "mock_client_tests"
path = "tests/mock_client_tests.rs"
[[test]]
name = "mock_edge_tests"
path = "tests/mock_edge_tests.rs"
[[test]]
name = "model_string_test"
path = "tests/model_string_test.rs"
[[test]]
name = "nested_enum_tests"
path = "tests/nested_enum_tests.rs"
[[test]]
name = "nested_struct_tests"
path = "tests/nested_struct_tests.rs"
[[test]]
name = "nested_validation_tests"
path = "tests/nested_validation_tests.rs"
[[test]]
name = "offline_smoke_tests"
path = "tests/offline_smoke_tests.rs"
[[test]]
name = "openai_enum_anyof_test"
path = "tests/openai_enum_anyof_test.rs"
[[test]]
name = "openai_multimodal_tests"
path = "tests/openai_multimodal_tests.rs"
[[test]]
name = "provider_offline_tests"
path = "tests/provider_offline_tests.rs"
[[test]]
name = "recursive_structures_tests"
path = "tests/recursive_structures_tests.rs"
[[test]]
name = "schema_builder_tests"
path = "tests/schema_builder_tests.rs"
[[test]]
name = "schema_validation_tests"
path = "tests/schema_validation_tests.rs"
[[test]]
name = "serde_rename_tests"
path = "tests/serde_rename_tests.rs"
[[test]]
name = "streaming_tests"
path = "tests/streaming_tests.rs"
[[test]]
name = "timeout_tests"
path = "tests/timeout_tests.rs"
[[test]]
name = "tool_calling_tests"
path = "tests/tool_calling_tests.rs"
[[test]]
name = "validate_method_tests"
path = "tests/validate_method_tests.rs"
[[test]]
name = "validation_recursion_tests"
path = "tests/validation_recursion_tests.rs"
[[test]]
name = "validation_tests"
path = "tests/validation_tests.rs"
[[test]]
name = "weird_types_tests"
path = "tests/weird_types_tests.rs"
[dependencies.async-stream]
version = "0.3.6"
optional = true
[dependencies.async-trait]
version = "0.1.89"
[dependencies.base64]
version = "0.22.1"
optional = true
[dependencies.futures-util]
version = "0.3.31"
optional = true
default-features = false
[dependencies.reqwest]
version = "0.13.3"
features = [
"json",
"query",
"default-tls",
]
optional = true
default-features = false
[dependencies.rstructor_derive]
version = "0.3.2"
optional = true
[dependencies.serde]
version = "1.0.228"
features = ["derive"]
[dependencies.serde_json]
version = "1.0.149"
[dependencies.thiserror]
version = "2.0.18"
[dependencies.tokio]
version = "1.52.1"
features = [
"rt",
"macros",
"rt-multi-thread",
"io-std",
]
optional = true
[dependencies.tracing]
version = "0.1.44"
[dependencies.tracing-futures]
version = "0.2.5"
optional = true
[dependencies.tracing-subscriber]
version = "0.3.23"
features = ["env-filter"]
optional = true
[dev-dependencies.chrono]
version = "0.4.44"
features = ["serde"]
[dev-dependencies.mockito]
version = "1.7.0"
[dev-dependencies.tokio]
version = "1.52.1"
features = [
"rt",
"macros",
"rt-multi-thread",
]