{"id":13456678,"url":"https://github.com/leptonai/leptonai","last_synced_at":"2026-05-07T03:02:26.603Z","repository":{"id":194888277,"uuid":"688186076","full_name":"leptonai/leptonai","owner":"leptonai","description":"A Pythonic framework to simplify AI service building","archived":false,"fork":false,"pushed_at":"2026-04-16T00:23:46.000Z","size":7468,"stargazers_count":2802,"open_issues_count":22,"forks_count":194,"subscribers_count":24,"default_branch":"main","last_synced_at":"2026-04-16T00:30:26.278Z","etag":null,"topics":["artificial-intelligence","cloud","deep-learning","gpu","machine-learning","python"],"latest_commit_sha":null,"homepage":"https://lepton.ai/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leptonai.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-09-06T20:38:00.000Z","updated_at":"2026-04-16T00:22:28.000Z","dependencies_parsed_at":"2025-11-29T04:06:29.520Z","dependency_job_id":null,"html_url":"https://github.com/leptonai/leptonai","commit_stats":{"total_commits":564,"total_committers":19,"mean_commits":29.68421052631579,"dds":0.5904255319148937,"last_synced_commit":"5fa7fe8ee8154d07f029ce7d70d68596606feba8"},"previous_names":["leptonai/leptonai-sdk","leptonai/leptonai"],"tags_count":82,"template":false,"template_full_name":null,"purl":"pkg:github/leptonai/leptonai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leptonai%2Fleptonai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leptonai%2Fleptonai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leptonai%2Fleptonai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leptonai%2Fleptonai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leptonai","download_url":"https://codeload.github.com/leptonai/leptonai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leptonai%2Fleptonai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31867712,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"online","status_checked_at":"2026-04-16T02:00:06.042Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["artificial-intelligence","cloud","deep-learning","gpu","machine-learning","python"],"created_at":"2024-07-31T08:01:25.877Z","updated_at":"2026-04-16T02:01:00.832Z","avatar_url":"https://github.com/leptonai.png","language":"Python","funding_links":[],"categories":["Python","Project List","Deployment and Serving","A01_文本生成_文本对话","cloud","Repos"],"sub_categories":["\u003cspan id=\"tool\"\u003eLLM (LLM \u0026 Tool)\u003c/span\u003e","大语言对话模型及数据"],"readme":"\u003cimg src=\"https://raw.githubusercontent.com/leptonai/leptonai/main/assets/logo.svg\" height=100\u003e\n\n# Lepton AI\n\n**A Pythonic framework to simplify AI service building**\n\n\u003ca href=\"https://docs.nvidia.com/dgx-cloud/lepton\"\u003eHomepage\u003c/a\u003e •\n\u003ca href=\"https://github.com/leptonai/examples\"\u003eExamples\u003c/a\u003e •\n\u003ca href=\"https://docs.nvidia.com/dgx-cloud/lepton\"\u003eDocumentation\u003c/a\u003e •\n\u003ca href=\"https://docs.nvidia.com/dgx-cloud/lepton/reference/cli\"\u003eCLI References\u003c/a\u003e\n\nThe LeptonAI Python library allows you to build an AI service from Python code with ease. Key features include:\n\n- A Pythonic abstraction `Photon`, allowing you to convert research and modeling code into a service with a few lines of code.\n- Simple abstractions to launch models like those on [HuggingFace](https://huggingface.co) in few lines of code.\n- Prebuilt examples for common models such as Llama, SDXL, Whisper, and others.\n- AI tailored batteries included such as autobatching, background jobs, etc.\n- A client to automatically call your service like native Python functions.\n- Pythonic configuration specs to be readily shipped in a cloud environment.\n\n## Getting started with one-liner\nInstall the library with:\n\n```shell\npip install -U leptonai\n```\nThis installs the `leptonai` Python library, as well as the commandline interface `lep`. You can then launch a HuggingFace model, say `gpt2`, in one line of code:\n\n```python\nlep photon runlocal --name gpt2 --model hf:gpt2\n```\n\nIf you have access to the Llama2 model ([apply for access here](https://huggingface.co/meta-llama/Llama-2-7b)) and you have a reasonably sized GPU, you can launch it with:\n\n```python\n# hint: you can also write `-n` and `-m` for short\nlep photon runlocal -n llama2 -m hf:meta-llama/Llama-2-7b-chat-hf\n```\n\n(Be sure to use the `-hf` version for Llama2, which is compatible with huggingface pipelines.)\n\nYou can then access the service with:\n\n```python\nfrom leptonai.client import Client, local\nc = Client(local(port=8080))\n# Use the following to print the doc\nprint(c.run.__doc__)\nprint(c.run(inputs=\"I enjoy walking with my cute dog\"))\n```\n\nNot all HuggingFace models are supported, as many of them contain custom code and are not standard pipelines. If you find a popular model you would like to support, please [open an issue or a PR](https://github.com/leptonai/leptonai/issues/new).\n\n## Checking out more examples\n\nYou can find out more examples from the [examples repository](https://github.com/leptonai/examples). For example, launch the Stable Diffusion XL model with:\n\n```shell\ngit clone git@github.com:leptonai/examples.git\ncd examples\n```\n\n```python\nlep photon runlocal -n sdxl -m advanced/sdxl/sdxl.py\n```\n\nOnce the service is running, you can access it with:\n\n```python\nfrom leptonai.client import Client, local\n\nc = Client(local(port=8080))\n\nimg_content = c.run(prompt=\"a cat launching rocket\", seed=1234)\nwith open(\"cat.png\", \"wb\") as fid:\n    fid.write(img_content)\n```\n\nor access the mounted Gradio UI at [http://localhost:8080/ui](http://localhost:8080/ui). Check the [README file](https://github.com/leptonai/examples/blob/main/advanced/sdxl/README.md) for more details.\n\n## Writing your own photons\n\nWriting your own photon is simple: write a Python Photon class and decorate functions with `@Photon.handler`. As long as your input and output are JSON serializable, you are good to go. For example, the following code launches a simple echo service:\n\n```python\n# my_photon.py\nfrom leptonai.photon import Photon\n\nclass Echo(Photon):\n    @Photon.handler\n    def echo(self, inputs: str) -\u003e str:\n        \"\"\"\n        A simple example to return the original input.\n        \"\"\"\n        return inputs\n```\n\nYou can then launch the service with:\n\n```shell\nlep photon runlocal -n echo -m my_photon.py\n```\n\nThen, you can use your service as follows:\n```python\nfrom leptonai.client import Client, local\n\nc = Client(local(port=8080))\n\n# will print available paths\nprint(c.paths())\n# will print the doc for c.echo. You can also use `c.echo?` in Jupyter.\nprint(c.echo.__doc__)\n# will actually call echo.\nc.echo(inputs=\"hello world\")\n```\n\nFor more details, checkout the [documentation](https://docs.nvidia.com/dgx-cloud/lepton) and the [examples](https://github.com/leptonai/examples).\n\n## Contributing\n\nContributions and collaborations are welcome and highly appreciated. Please check out the [contributor guide](https://github.com/leptonai/leptonai/blob/main/CONTRIBUTING.md) for how to get involved.\n\n## License\n\nThe Lepton AI Python library is released under the Apache 2.0 license.\n\nDeveloper Note: early development of LeptonAI was in a separate mono-repo, which is why you may see commits from the `leptonai/lepton` repo. We intend to use this open source repo as the source of truth going forward.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleptonai%2Fleptonai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleptonai%2Fleptonai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleptonai%2Fleptonai/lists"}