{"data":{"slug":"abraxas-365-langchain-rust","name":"langchain-rust","tagline":"🦜️🔗LangChain for Rust, the easiest way to write LLM-based programs in Rust","github_url":"https://github.com/Abraxas-365/langchain-rust","owner":"Abraxas-365","repo":"langchain-rust","owner_avatar_url":"https://avatars.githubusercontent.com/u/63959220?v=4","primary_language":"Rust","stars":1327,"forks":176,"topics":["langchain","llm","llms","openai","rust"],"archived":false,"github_pushed_at":"2026-07-10T09:46:20+00:00","maintenance_label":"Very active","url":"https://www.graphcanon.com/tools/abraxas-365-langchain-rust","markdown_url":"https://www.graphcanon.com/tools/abraxas-365-langchain-rust.md","api_url":"https://www.graphcanon.com/api/graphcanon/tools/abraxas-365-langchain-rust","graph_url":"https://www.graphcanon.com/api/graphcanon/graph?tool=abraxas-365-langchain-rust","description":"🦜️🔗LangChain for Rust, the easiest way to write LLM-based programs in Rust","homepage_url":null,"license":"MIT","open_issues":81,"watchers":14,"ai_summary":null,"readme_excerpt":"## Installation\n\nThis library heavily relies on `serde_json` for its operation.\n\n---\n\n### Quick Start Conversational Chain\n\n```rust\nuse langchain_rust::{\n    chain::{Chain, LLMChainBuilder},\n    fmt_message, fmt_placeholder, fmt_template,\n    language_models::llm::LLM,\n    llm::openai::{OpenAI, OpenAIModel},\n    message_formatter,\n    prompt::HumanMessagePromptTemplate,\n    prompt_args,\n    schemas::messages::Message,\n    template_fstring,\n};\n\n#[tokio::main]\nasync fn main() {\n    //We can then initialize the model:\n    // If you'd prefer not to set an environment variable you can pass the key in directly via the `openai_api_key` named parameter when initiating the OpenAI LLM class:\n    // let open_ai = OpenAI::default()\n    //     .with_config(\n    //         OpenAIConfig::default()\n    //             .with_api_key(\"<your_key>\"),\n    //     ).with_model(OpenAIModel::Gpt4oMini.to_string());\n    let open_ai = OpenAI::default().with_model(OpenAIModel::Gpt4oMini.to_string());\n\n\n    //Once you've installed and initialized the LLM of your choice, we can try using it! Let's ask it what LangSmith is - this is something that wasn't present in the training data so it shouldn't have a very good response.\n    let resp = open_ai.invoke(\"What is rust\").await.unwrap();\n    println!(\"{}\", resp);\n\n    // We can also guide it's response with a prompt template. Prompt templates are used to convert raw user input to a better input to the LLM.\n    let prompt = message_formatter![\n        fmt_message!(Message::new_system_message(\n            \"You are world class technical documentation writer.\"\n        )),\n        fmt_template!(HumanMessagePromptTemplate::new(template_fstring!(\n            \"{input}\", \"input\"\n        )))\n    ];\n\n    //We can now combine these into a simple LLM chain:\n\n    let chain = LLMChainBuilder::new()\n        .prompt(prompt)\n        .llm(open_ai.clone())\n        .build()\n        .unwrap();\n\n    //We can now invoke it and ask the same question. It still won't know the answer, but it should respond in a more proper tone for a technical writer!\n\n    match chain\n        .invoke(prompt_args! {\n        \"input\" => \"Quien es el escritor de 20000 millas de viaje submarino\",\n           })\n        .await\n    {\n        Ok(result) => {\n            println!(\"Result: {:?}\", result);\n        }\n        Err(e) => panic!(\"Error invoking LLMChain: {:?}\", e),\n    }\n\n    //If you want to prompt to have a list of messages you could use the `fmt_placeholder` macro\n\n    let prompt = message_formatter![\n        fmt_message!(Message::new_system_message(\n            \"You are world class technical documentation writer.\"\n        )),\n        fmt_placeholder!(\"history\"),\n        fmt_template!(HumanMessagePromptTemplate::new(template_fstring!(\n            \"{input}\", \"input\"\n        ))),\n    ];\n\n    let chain = LLMChainBuilder::new()\n        .prompt(prompt)\n        .llm(open_ai)\n        .build()\n        .unwrap();\n    match chain\n        .invoke(prompt_args! {\n        \"input\" => \"Who is the writer of 20,000 Leagues Under the Sea, and what is my name?\",\n        \"history\" => vec![\n                Message::new_human_message(\"My name is: luis\"),\n                Message::new_ai_message(\"Hi luis\"),\n                ],\n\n        })\n        .await\n    {\n        Ok(result) => {\n            println!(\"Result: {:?}\", result);\n        }\n        Err(e) => panic!(\"Error invoking LLMChain: {:?}\", e),\n    }\n}\n```","github_created_at":"2024-01-31T14:40:00+00:00","created_at":"2026-07-11T10:43:39.325768+00:00","updated_at":"2026-07-11T10:43:46.489299+00:00","categories":[{"slug":"llm-frameworks","name":"LLM Frameworks","url":"https://www.graphcanon.com/categories/llm-frameworks","markdown_url":"https://www.graphcanon.com/categories/llm-frameworks.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/llm-frameworks"},{"slug":"model-training","name":"Model Training","url":"https://www.graphcanon.com/categories/model-training","markdown_url":"https://www.graphcanon.com/categories/model-training.md","api_url":"https://www.graphcanon.com/api/graphcanon/categories/model-training"}],"tags":[{"slug":"llms","name":"llms"},{"slug":"llm","name":"llm"},{"slug":"rust","name":"rust"},{"slug":"openai","name":"openai"},{"slug":"langchain","name":"langchain"}],"trust":{"provenance":{"is_fork":false,"github_id":750896555,"owner_type":"User","methodology":"github_public_v1","parent_repo":null,"near_duplicate_slugs":[]},"computed_at":"2026-07-11T10:43:40.060Z","maintenance":{"label":"Very active","score":96,"methodology":"github_public_v1","releases_90d":0,"days_since_push":1,"last_release_at":"2024-10-06T18:24:34Z"},"security_summary":{"status":"no_lockfile","scanner":null,"low_count":0,"high_count":0,"last_scan_at":"2026-07-11T10:43:44.758Z","medium_count":0,"scan_profile":"none","critical_count":0}},"capability_facts":{"scan":{"source":"repo_scan","observed_at":"2026-07-11T10:43:44.453Z"},"languages":{"value":["rust"],"source":"github.language","observed_at":"2026-07-11T10:43:44.453Z"},"license_spdx":{"value":"MIT","source":"github.license","observed_at":"2026-07-11T10:43:44.453Z"}}}}