{"id":26831333,"url":"https://github.com/benjaminbwright/fastapi-chat-completion-template","last_synced_at":"2025-06-29T15:05:51.514Z","repository":{"id":284573195,"uuid":"954931839","full_name":"benjaminbwright/fastAPI-chat-completion-template","owner":"benjaminbwright","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-19T14:55:55.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-29T15:05:46.827Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benjaminbwright.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2025-03-25T20:54:26.000Z","updated_at":"2025-06-19T14:55:59.000Z","dependencies_parsed_at":"2025-03-26T15:55:55.733Z","dependency_job_id":"bc6e1a6c-31c4-4e9b-ae6b-d3c75b1dc4b4","html_url":"https://github.com/benjaminbwright/fastAPI-chat-completion-template","commit_stats":null,"previous_names":["benjaminbwright/fastapi-chat-completion-template"],"tags_count":0,"template":true,"template_full_name":"benjaminbwright/fastAPI-template","purl":"pkg:github/benjaminbwright/fastAPI-chat-completion-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminbwright%2FfastAPI-chat-completion-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminbwright%2FfastAPI-chat-completion-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminbwright%2FfastAPI-chat-completion-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminbwright%2FfastAPI-chat-completion-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benjaminbwright","download_url":"https://codeload.github.com/benjaminbwright/fastAPI-chat-completion-template/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benjaminbwright%2FfastAPI-chat-completion-template/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262614456,"owners_count":23337277,"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":[],"created_at":"2025-03-30T14:32:11.879Z","updated_at":"2025-06-29T15:05:51.471Z","avatar_url":"https://github.com/benjaminbwright.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastAPI Chat Completion Template\n\nA modern, modular FastAPI template for building chat completion APIs using LangChain and Anthropic's Claude.\n\n## Features\n\n- FastAPI-based REST API\n- LangChain integration with Anthropic's Claude\n- Modular service architecture\n- Async support\n- Conversation history management\n- Environment-based configuration\n- Type hints and validation\n\n## Prerequisites\n\n- Python 3.8+\n- Anthropic API key\n\n## Installation\n\n1. Clone the repository:\n\n```bash\ngit clone https://github.com/yourusername/fastAPI-chat-completion-template.git\ncd fastAPI-chat-completion-template\n```\n\n2. Create and activate a virtual environment:\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate  # On Windows: .venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n4. Set up environment variables:\n\n```bash\ncp .env.EXAMPLE .env\n# Edit .env with your Anthropic API key\n```\n\n## Project Structure\n\n```\n.\n├── api/\n│   └── routes/\n│       └── chat_routes.py    # API endpoints\n├── models/\n│   └── chat.py              # Pydantic models\n├── services/\n│   ├── base.py              # Base service class\n│   └── chat/\n│       ├── base.py          # Base chat service\n│       └── anthropic.py     # Anthropic implementation\n├── main.py                  # Application entry point\n├── requirements.txt         # Project dependencies\n└── .env                     # Environment variables\n```\n\n## Usage\n\n1. Start the server:\n\n```bash\npython -m uvicorn main:app --reload\n```\n\n2. Access the API documentation:\n\n- Swagger UI: http://localhost:8001/docs\n- ReDoc: http://localhost:8001/redoc\n\n## API Endpoints\n\n### Chat Completion\n\n- `POST /api/chat/completions`\n  ```json\n  {\n    \"message\": {\n      \"content\": \"Your message here\",\n      \"role\": \"user\" // optional, defaults to \"user\"\n    }\n  }\n  ```\n\n### Chat History\n\n- `GET /api/chat/history` - Get conversation history\n- `DELETE /api/chat/history` - Clear conversation history\n\n## Development\n\n### Adding New Chat Providers\n\n1. Create a new service class in `services/chat/`\n2. Inherit from `BaseChatService`\n3. Implement the `get_chat_response` method\n4. Update the service factory in `api/routes/chat_routes.py`\n\n### Running Tests\n\n```bash\npytest\n```\n\n## Contributing\n\n1. Fork the repository\n2. Create a feature branch\n3. Commit your changes\n4. Push to the branch\n5. Create a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n## Acknowledgments\n\n- FastAPI\n- LangChain\n- Anthropic\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminbwright%2Ffastapi-chat-completion-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenjaminbwright%2Ffastapi-chat-completion-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenjaminbwright%2Ffastapi-chat-completion-template/lists"}