{"id":16270968,"url":"https://github.com/mdegans/misanthropic","last_synced_at":"2025-10-05T09:30:35.285Z","repository":{"id":254502201,"uuid":"846751277","full_name":"mdegans/misanthropic","owner":"mdegans","description":"Simple, ergonomic, async, Rust client for Anthropic’s Messages API","archived":false,"fork":false,"pushed_at":"2025-01-11T22:42:28.000Z","size":162,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-11T23:31:50.622Z","etag":null,"topics":["anthropic","async","claude","client","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdegans.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-23T22:00:31.000Z","updated_at":"2024-11-30T01:23:42.000Z","dependencies_parsed_at":"2024-11-08T00:22:10.348Z","dependency_job_id":"f85146db-1450-49b3-b707-c98bcfa42744","html_url":"https://github.com/mdegans/misanthropic","commit_stats":{"total_commits":16,"total_committers":1,"mean_commits":16.0,"dds":0.0,"last_synced_commit":"f9f51753faa5d701de2d23bdf464c62f713e45f4"},"previous_names":["mdegans/misanthropic"],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdegans%2Fmisanthropic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdegans%2Fmisanthropic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdegans%2Fmisanthropic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdegans%2Fmisanthropic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdegans","download_url":"https://codeload.github.com/mdegans/misanthropic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235378951,"owners_count":18980492,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anthropic","async","claude","client","rust"],"created_at":"2024-10-10T18:12:05.302Z","updated_at":"2025-10-05T09:30:30.010Z","avatar_url":"https://github.com/mdegans.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `misanthropic`\n\n![Build Status](https://github.com/mdegans/misanthropic/actions/workflows/tests.yaml/badge.svg)\n[![codecov](https://codecov.io/gh/mdegans/misanthropic/branch/main/graph/badge.svg)](https://codecov.io/gh/mdegans/misanthropic)\n\nIs an unofficial simple, ergonomic, client for the Anthropic Messages API.\n\n## Usage\n\n### Streaming\n\n```rust\n// Create a client. The key is encrypted in memory and source string is zeroed.\n// When requests are made, the key header is marked as sensitive.\nlet client = Client::new(key)?;\n\n// Request a stream of events or errors. `json!` can be used, the `Prompt`\n// builder pattern (shown in the `Single Message` example below), or anything\n// serializable.\nlet stream = client\n    // Forces `stream=true` in the request.\n    .stream(json!({\n      \"model\": Model::Sonnet35,\n      \"max_tokens\": args.max_tokens,\n      \"temperature\": 0,\n      \"system\": args.system,\n      \"messages\": [\n        {\n          \"role\": Role::User,\n          \"content\": specs,\n        }\n      ],\n    }))\n    .await?\n    // Filter out rate limit and overloaded errors. This is optional but\n    // recommended for most use cases. The stream will continue when the\n    // server is ready. Otherwise the stream will include these errors.\n    .filter_rate_limit()\n    // Filter out everything but text pieces (and errors).\n    .text();\n\n// Collect the stream into a single string.\nlet content: String = stream\n    .try_collect()\n    .await?;\n```\n\n### Single Message\n\n```rust\nlet client = Client::new(key)?;\n\n// Many common usage patterns are supported out of the box for building\n// `Prompt`s, such as messages from an iterable of tuples of `Role` and\n// `String`.\nlet message = client\n    .message(Prompt::default().messages([(Role::User, args.prompt)]))\n    .await?;\n\nprintln!(\"{}\", message);\n```\n\n## Features\n\n- [x] Async but does not _directly_ depend on tokio\n- [x] Tool use,\n- [x] Streaming responses\n- [x] Message responses\n- [x] Image support with or without the `image` crate\n- [x] Markdown formatting of messages, including images\n- [x] HTML formatting of messages\\*.\n- [x] Prompt caching support\n- [x] Custom request and endpoint support\n- [x] Zero-copy where possible\n- [x] [Sanitization](https://crates.io/crates/langsan) of input and output to mitigate [injection attacks](https://arstechnica.com/security/2024/10/ai-chatbots-can-read-and-write-invisible-text-creating-an-ideal-covert-channel/)\n- [ ] Amazon Bedrock support\n- [ ] Vertex AI support\n\n\\* _Base64 encoded images are currently not implemented for HTML but this is a planned feature._\n\n[reqwest]: https://docs.rs/reqwest\n\n## FAQ\n\n- **Why is it called `misanthropic`?** No reason, really. I just like the word.\n  Anthropic is both a company and a word meaning \"relating to mankind\". This\n  crate is neither official or related to mankind so, `misanthropic` it is.\n- **Doesn't `reqwest` depend on `tokio`?** On some platforms, yes.\n- **Can i use `misanthropic` with Amazon or Vertex?** Not yet, but it's on the\n  roadmap. for now the `Client` does support custom endpoints and the inner\n  `reqwest::Client` can be accessed directly to make necessary adjustments to\n  headers, etc.\n- **Has this crate been audited?** No, but auditing is welcome. A best effort\n  has been made to ensure security and privacy. The API key is encrypted in\n  memory using the `memsecurity` crate and any headers containing copies marked\n  as sensitive. `rustls` is an optional feature and is recommended for security.\n  It is on by default.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdegans%2Fmisanthropic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdegans%2Fmisanthropic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdegans%2Fmisanthropic/lists"}