{"id":22683500,"url":"https://github.com/notedit/dify2openai","last_synced_at":"2025-03-29T14:41:03.325Z","repository":{"id":255888826,"uuid":"853811531","full_name":"notedit/dify2openai","owner":"notedit","description":"dify to  openai  api","archived":false,"fork":false,"pushed_at":"2024-09-08T07:32:32.000Z","size":5,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-04T15:43:44.277Z","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/notedit.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}},"created_at":"2024-09-07T15:50:41.000Z","updated_at":"2024-09-08T12:01:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"703d4b91-5b68-4600-b7b9-79c10a42b182","html_url":"https://github.com/notedit/dify2openai","commit_stats":null,"previous_names":["notedit/dify2openai"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notedit%2Fdify2openai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notedit%2Fdify2openai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notedit%2Fdify2openai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notedit%2Fdify2openai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notedit","download_url":"https://codeload.github.com/notedit/dify2openai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246200300,"owners_count":20739563,"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":"2024-12-09T21:12:21.340Z","updated_at":"2025-03-29T14:41:03.313Z","avatar_url":"https://github.com/notedit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dify2openai\n\n\n\n### 安装说明\n\n1. 确保已安装 Python 3.7+。\n\n2. 创建并激活虚拟环境（可选但推荐）：\n```bash\npython -m venv venv\nsource venv/bin/activate  # 在 Windows 上使用 venv\\Scripts\\activate\n```\n\n3. 安装所需依赖：\n```bash\npip install -r requirements.txt\n```\n\n4. 创建一个 `.env` 文件，并添加您的 Dify API 密钥：\n```\nDIFY_API_KEY=your_dify_api_key_here\n```\n\n### 使用说明\n\n1. 确保 `main.py` 和 `difyapi.py` 文件在同一目录下。\n\n2. 运行 FastAPI 服务器：\n```bash\npython main.py\n```\n\n3. 服务器将在 `http://0.0.0.0:8000` 上运行。\n\n4. 要使用聊天功能，向 `/chat/completions` 端点发送 POST 请求，格式如下：\n```json\n{\n  \"messages\": [\n    {\"role\": \"user\", \"content\": \"你好，请介绍一下自己。\"}\n  ]\n}\n```\n\n5. 如果需要保持对话上下文，可以在请求头中添加 `X-Task-Id`。\n\n6. 服务器将以 Server-Sent Events (SSE) 格式返回流式响应。\n\n注意：确保您有有效的 Dify API 密钥，并且了解 Dify API 的使用条款和限制。\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotedit%2Fdify2openai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotedit%2Fdify2openai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotedit%2Fdify2openai/lists"}