{"id":22065417,"url":"https://github.com/tryagi/anthropic","last_synced_at":"2025-05-13T01:15:58.368Z","repository":{"id":181333968,"uuid":"666587771","full_name":"tryAGI/Anthropic","owner":"tryAGI","description":"C# SDK based on Anthropic OpenAPI specification","archived":false,"fork":false,"pushed_at":"2025-05-12T07:32:11.000Z","size":1262,"stargazers_count":25,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-13T01:15:44.780Z","etag":null,"topics":["ai","anthropic","api","autosdk","claude","claude-api","csharp","dotnet","generated","langchain","langchain-dotnet","llm","llms","nswag","openapi","sdk","tokenizer"],"latest_commit_sha":null,"homepage":"https://tryagi.github.io/Anthropic/","language":"C#","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/tryAGI.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,"zenodo":null},"funding":{"github":"HavenDV","patreon":"havendv","ko_fi":"havendv","custom":["https://www.paypal.me/havendv","https://www.buymeacoffee.com/havendv","https://donate.stripe.com/00gfZ19zkeKLh1eaEE","https://www.upwork.com/freelancers/~017b1ad6f6af9cc189"]}},"created_at":"2023-07-14T23:21:11.000Z","updated_at":"2025-05-12T07:32:13.000Z","dependencies_parsed_at":"2023-07-15T02:28:54.720Z","dependency_job_id":"c9fbecce-6c70-40b2-82ad-3eaa0f43c1c1","html_url":"https://github.com/tryAGI/Anthropic","commit_stats":null,"previous_names":["tryagi/anthropic"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryAGI%2FAnthropic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryAGI%2FAnthropic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryAGI%2FAnthropic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tryAGI%2FAnthropic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tryAGI","download_url":"https://codeload.github.com/tryAGI/Anthropic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253851075,"owners_count":21973674,"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":["ai","anthropic","api","autosdk","claude","claude-api","csharp","dotnet","generated","langchain","langchain-dotnet","llm","llms","nswag","openapi","sdk","tokenizer"],"created_at":"2024-11-30T19:17:29.993Z","updated_at":"2025-05-13T01:15:58.360Z","avatar_url":"https://github.com/tryAGI.png","language":"C#","funding_links":["https://github.com/sponsors/HavenDV","https://patreon.com/havendv","https://ko-fi.com/havendv","https://www.paypal.me/havendv","https://www.buymeacoffee.com/havendv","https://donate.stripe.com/00gfZ19zkeKLh1eaEE","https://www.upwork.com/freelancers/~017b1ad6f6af9cc189"],"categories":[],"sub_categories":[],"readme":"# Anthropic\n\n[![Nuget package](https://img.shields.io/nuget/vpre/Anthropic)](https://www.nuget.org/packages/Anthropic/)\n[![dotnet](https://github.com/tryAGI/Anthropic/actions/workflows/dotnet.yml/badge.svg?branch=main)](https://github.com/tryAGI/Anthropic/actions/workflows/dotnet.yml)\n[![License: MIT](https://img.shields.io/github/license/tryAGI/Anthropic)](https://github.com/tryAGI/Anthropic/blob/main/LICENSE.txt)\n[![Discord](https://img.shields.io/discord/1115206893015662663?label=Discord\u0026logo=discord\u0026logoColor=white\u0026color=d82679)](https://discord.gg/Ca2xhfBf3v)\n\n## Features 🔥\n- Fully generated C# SDK based on [official OpenAPI specification](https://raw.githubusercontent.com/anthropics/anthropic-sdk-typescript/refs/heads/main/.stats.yml) using [AutoSDK](https://github.com/HavenDV/OpenApiGenerator)\n- Automatic releases of new preview versions if there was an update to the OpenAPI specification\n- Source generator to define tools natively through C# interfaces\n- All modern .NET features - nullability, trimming, NativeAOT, etc.\n- Support .Net Framework/.Net Standard 2.0\n- Supporting [Microsoft.Extensions.AI](https://devblogs.microsoft.com/dotnet/introducing-microsoft-extensions-ai-preview/)\n- Supports all endpoints of the API, including batch requests, count tokens, and prompt caching.\n\n## Usage\n```csharp\nusing Anthropic;\n\nusing var client = new AnthropicClient(apiKey);\n\nvar messageParams = new CreateMessageParams()\n{   \n    Model = new Model(ModelVariant6.Claude35SonnetLatest),\n    Messages = [\n        new InputMessage(InputMessageRole.User, \"What's the weather like today?\"),\n        new InputMessage(InputMessageRole.Assistant, \"Sure! Could you please provide me with your location?\"),\n        new InputMessage(InputMessageRole.User, \"Dubai, UAE\")\n    ],\n    MaxTokens = 250\n};\nvar response = await client.Messages.MessagesPostAsync(messageParams);\n```\n\n### Tools\n```csharp\nusing CSharpToJsonSchema;\n\npublic enum Unit\n{\n    Celsius,\n    Fahrenheit,\n}\n\npublic class Weather\n{\n    public string Location { get; set; } = string.Empty;\n    public double Temperature { get; set; }\n    public Unit Unit { get; set; }\n    public string Description { get; set; } = string.Empty;\n}\n\n[GenerateJsonSchema]\npublic interface IWeatherFunctions\n{\n    [Description(\"Get the current weather in a given location\")]\n    public Weather GetCurrentWeather(\n        [Description(\"The city and state, e.g. San Francisco, CA\")] string location,\n        Unit unit = Unit.Celsius);\n    \n    [Description(\"Get the current weather in a given location\")]\n    public Task\u003cWeather\u003e GetCurrentWeatherAsync(\n        [Description(\"The city and state, e.g. San Francisco, CA\")] string location,\n        Unit unit = Unit.Celsius,\n        CancellationToken cancellationToken = default);\n}\n\npublic class WeatherService : IWeatherFunctions\n{\n    public Weather GetCurrentWeather(string location, Unit unit = Unit.Celsius)\n    {\n        return new Weather\n        {\n            Location = location,\n            Temperature = 22.0,\n            Unit = unit,\n            Description = \"Sunny\",\n        };\n    }\n    \n    public Task\u003cWeather\u003e GetCurrentWeatherAsync(string location, Unit unit = Unit.Celsius, CancellationToken cancellationToken = default)\n    {\n        return Task.FromResult(new Weather\n        {\n            Location = location,\n            Temperature = 22.0,\n            Unit = unit,\n            Description = \"Sunny\",\n        });\n    }\n}\n```\n```csharp\nusing Anthropic;\n\nusing var client = new AnthropicClient(apiKey);\n\nvar service = new WeatherService();\nvar tools = service.AsTools();\n\nvar messageParams = new CreateMessageParams()\n{   \n    Model = new Model(ModelVariant6.Claude35SonnetLatest),\n    Messages = [new InputMessage(InputMessageRole.User, \"What is the current temperature in Dubai, UAE in Celsius?\")],\n    MaxTokens = 4096,\n    System = \"You are a helpful weather assistant.\",\n    ToolChoice = new ToolChoice(new ToolChoiceAuto()),\n    Tools = tools\n};\nvar response = await client.Messages.MessagesPostAsync(messageParams);\n\nmessageParams.Messages.Add(response.AsInputMessage());\n\nforeach (var toolUse in response.Content.Value2!\n     .Where(x =\u003e x.IsToolUse)\n     .Select(x =\u003e x.ToolUse))\n{\n    var json = await service.CallAsync(\n        functionName: toolUse!.Name,\n        argumentsAsJson: toolUse.Input.AsJson());\n    messageParams.Messages.Add(json.AsToolCall(toolUse));\n}\n\nresponse = await client.Messages.MessagesPostAsync(messageParams);\n```\n\n## Support\n\nPriority place for bugs: https://github.com/tryAGI/Anthropic/issues  \nPriority place for ideas and general questions: https://github.com/tryAGI/Anthropic/discussions  \nDiscord: https://discord.gg/Ca2xhfBf3v  \n\n## Acknowledgments\n\n![JetBrains logo](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.png)\n\nThis project is supported by JetBrains through the [Open Source Support Program](https://jb.gg/OpenSourceSupport).\n\n![CodeRabbit logo](https://opengraph.githubassets.com/1c51002d7d0bbe0c4fd72ff8f2e58192702f73a7037102f77e4dbb98ac00ea8f/marketplace/coderabbitai)\n\nThis project is supported by CodeRabbit through the [Open Source Support Program](https://github.com/marketplace/coderabbitai).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryagi%2Fanthropic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftryagi%2Fanthropic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftryagi%2Fanthropic/lists"}