{"id":22577141,"url":"https://github.com/patchoulish/lambda-dotnet","last_synced_at":"2026-02-25T13:07:23.956Z","repository":{"id":264743951,"uuid":"894131861","full_name":"patchoulish/lambda-dotnet","owner":"patchoulish","description":"A .NET library for interacting with the Lambda API","archived":false,"fork":false,"pushed_at":"2024-12-07T01:59:42.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T01:46:58.066Z","etag":null,"topics":["ai","api","cloud","compute","dotnet","lambda","lambdalabs"],"latest_commit_sha":null,"homepage":"","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/patchoulish.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-25T20:11:30.000Z","updated_at":"2024-12-07T01:59:46.000Z","dependencies_parsed_at":"2024-11-26T04:58:55.184Z","dependency_job_id":"bc0d9f5d-459e-4900-b795-df3d7df5fb6a","html_url":"https://github.com/patchoulish/lambda-dotnet","commit_stats":null,"previous_names":["patchoulish/lambda-dotnet"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patchoulish%2Flambda-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patchoulish%2Flambda-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patchoulish%2Flambda-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patchoulish%2Flambda-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patchoulish","download_url":"https://codeload.github.com/patchoulish/lambda-dotnet/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261937,"owners_count":21074226,"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","api","cloud","compute","dotnet","lambda","lambdalabs"],"created_at":"2024-12-08T04:11:58.257Z","updated_at":"2025-10-29T01:36:13.153Z","avatar_url":"https://github.com/patchoulish.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lambda-dotnet [![CI](https://github.com/patchoulish/lambda-dotnet/actions/workflows/ci.yml/badge.svg)](https://github.com/patchoulish/lambda-dotnet/actions/workflows/ci.yml)\nA .NET library for interacting with the [Lambda](https://lambdalabs.com/) API.\n\n\n## Installation\nInstall the library via [NuGet](https://www.nuget.org/packages/lambda-dotnet):\n```bash\ndotnet add package lambda-dotnet\n```\n\n### Extensions\nInstall optional library extensions for more functionality, depending on your use case.\n#### Dependency Injection\nIntegrate lambda-dotnet and your DI container of choice. Install the extension library via [NuGet](https://www.nuget.org/packages/lambda-dotnet-dependencyinjection):\n```bash\ndotnet add package lambda-dotnet-dependencyinjection\n```\n\n\n## Usage\n1. Obtain an API key from the [Lambda Cloud Dashboard](https://cloud.lambdalabs.com/api-keys) (requires a Lambda account).\n2. Pass the API key into a new instance of the `LambdaCloudService` class or use a configured `HttpClient` if advanced configuration (e.g., proxies) is required.\n3. Use the methods available on `LambdaCloudService` to interact with the Lambda Cloud API.\n\n### Initialization\nThe library can be initialized in three ways:\n#### Basic Initialization\nPass in your API key directly:\n```csharp\nvar lambdaCloud = new LambdaCloudService(\"YOUR_LAMBDA_API_KEY\");\n```\n#### Advanced Initialization\nUse an existing `HttpClient`, ensuring that `BaseAddress` and an `Authorization` header have been set:\n```csharp\nvar httpClient = new HttpClient\n{\n    BaseAddress = new Uri(\"https://cloud.lambdalabs.com/api/v1/\"),\n    Timeout = TimeSpan.FromSeconds(5)\n};\n\nhttpClient.DefaultRequestHeaders.Authorization =\n    new AuthenticationHeaderValue(\"Bearer\", \"YOUR_LAMBDA_API_KEY\");\n\nvar lambdaCloud = new LambdaCloudService(httpClient);\n```\n#### Dependency Injection\nIf you've installed the appropriate extension library.\n1. Register `LambdaCloudService` with your dependency container:\n```csharp\nservices.AddLambdaCloudHttpClient(options =\u003e\n{\n    options.BaseUrl = new Uri(\"https://cloud.lambdalabs.com/api/v1/\");\n    options.ApiKey = \"YOUR_LAMBDA_API_KEY\";\n});\n```\n2. Inject `ILambdaCloudService` where needed:\n```csharp\npublic class MyClass\n{\n    private readonly ILambdaCloudService lambdaCloud;\n\n    public MyClass(ILambdaCloudService lambdaCloud)\n    {\n        this.lambdaCloud = lambdaCloud;\n    }\n}\n```\n### List Instances\nTo list your running instances:\n```csharp\nvar instances = await lambdaCloud.Instances.GetAllAsync();\n```\nTo retrieve the details of an instance:\n```csharp\nvar instanceId = ...\n\nvar instance = await lambdaCloud.Instances.GetAsync(instanceId);\n```\n\n### List Instance Types\nTo list the instance types offered by Lambda Cloud and explore their specs as well as their region-specific availability:\n```csharp\nvar instanceTypeAvailabilities = lambdaCloud.Instances.GetAllTypeAvailabilityAsync();\n\nvar instanceTypesToLaunch = instanceTypeAvailabilities\n    .Where(x =\u003e x.Type.Specifications.GpuCount \u003e= 4)\n\t.Where(x =\u003e x.RegionsWithCapacity.Any())\n\t.Select(x =\u003e x.Type)\n```\n\n### Launching Instances\nYou can launch an instance in the following way:\n```csharp\nvar options = new LambdaCloudInstanceLaunchOptions()\n{\n    RegionName = \"us-east-1\",\n    TypeName = \"gpu_1x_a100_sxm4\",\n    KeyNames = [\n        \"my-ssh-key\"\n    ],\n    Quantity = 1\n}\n\nvar instance = await lambdaCloud.Instances.LaunchAsync(options);\n```\n\n### Restarting or Terminating Instances\nTo restart one or more running instances:\n```csharp\nvar instances = ...\n\nvar options = new LambdaCloudInstanceRestartOptions()\n{\n    Ids = [ instances[0].Id, instances[1].Id, ... ]\n}\n\nvar restartedInstances = await lambdaCloud.RestartAsync(options);\n```\nTo terminate one or more running instances:\n```csharp\nvar instances = ...\n\nvar options = new LambdaCloudInstanceTerminateOptions()\n{\n    Ids = [ instances[0].Id, instances[1].Id, ... ]\n}\n\nvar terminatedInstances = await lambdaCloud.TerminateAsync(options);\n```\n\n### List SSH Keys\nTo list the SSH keys saved in your account:\n```csharp\nvar keys = await lambdaCloud.Keys.GetAllAsync();\n```\n\n### Adding or Generating a SSH Key\nTo add an existing SSH key to your account:\n```csharp\nvar options = new LambdaCloudKeyAddOrGenerateOptions()\n{\n    Name = \"my-existing-key\",\n    PublicKey = \"\u003cYOUR_PUBLIC_KEY_HERE\u003e\"\n}\n\nvar key = await lambdaCloud.Keys.AddOrGenerateAsync(options);\n```\nTo generate a new SSH key pair:\n```csharp\nvar options =\n    new LambdaCloudKeyAddOrGenerateOptions()\n    {\n        Name = \"my-generated-key\",\n        PublicKey = null // Omit the public key\n    }\n\nvar key = await lambdaCloud.Keys.AddOrGenerateAsync(options);\n\n// Make sure to save the private key returned to you.\nawait File.WriteAllTextAsync(\n    \"my-generated-key.pem\",\n    key.PrivateKey);\n```\n\n### Deleting an SSH Key\nTo delete an SSH key from your account:\n```csharp\nvar key = ...\n\nawait lambdaCloud.Keys.DeleteAsync(key.Id);\n```\n\n### Listing Filesystems\nTo list your persistent storage filesystems:\n```csharp\nvar filesystems = await lambdaCloud.Filesystems.GetAllAsync();\n```\n\n## Documentation\nRefer to the [Usage](#usage) section above for a quick start, or consult the inline documentation while working in your IDE.\nFor detailed information about the underlying API endpoints, parameters, and expected responses, refer to Lambda's [Cloud API documentation](https://docs.lambdalabs.com/public-cloud/cloud-api/) as well as their [Cloud API reference](https://cloud.lambdalabs.com/api/v1/docs).\n\n\n## Contributing\nContributions are welcome! To contribute, fork the repository, create a new branch, and submit a pull request with your changes. Please make sure all tests pass before submitting.\n\n\n## License\nThis project is licensed under the MIT license. See `license.txt` for full details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatchoulish%2Flambda-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatchoulish%2Flambda-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatchoulish%2Flambda-dotnet/lists"}