{"id":29151442,"url":"https://github.com/cameronking4/azure-openai-responses-api","last_synced_at":"2025-08-02T12:36:22.800Z","repository":{"id":285729622,"uuid":"959124226","full_name":"cameronking4/azure-openai-responses-api","owner":"cameronking4","description":"A FastAPI application that provides various endpoints for interacting with Azure OpenAI's Responses API, including streaming, conversations, image analysis, and more.","archived":false,"fork":false,"pushed_at":"2025-04-04T13:18:15.000Z","size":382,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-01T00:09:10.417Z","etag":null,"topics":["azure-openai","responses-api"],"latest_commit_sha":null,"homepage":"https://az-openai-responses.azurewebsites.net","language":"Python","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/cameronking4.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":"2025-04-02T09:58:25.000Z","updated_at":"2025-04-28T14:49:11.000Z","dependencies_parsed_at":"2025-04-02T11:42:01.729Z","dependency_job_id":null,"html_url":"https://github.com/cameronking4/azure-openai-responses-api","commit_stats":null,"previous_names":["cameronking4/azure-openai-responses-api"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cameronking4/azure-openai-responses-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cameronking4%2Fazure-openai-responses-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cameronking4%2Fazure-openai-responses-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cameronking4%2Fazure-openai-responses-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cameronking4%2Fazure-openai-responses-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cameronking4","download_url":"https://codeload.github.com/cameronking4/azure-openai-responses-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cameronking4%2Fazure-openai-responses-api/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268390614,"owners_count":24243082,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"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":["azure-openai","responses-api"],"created_at":"2025-07-01T00:09:09.649Z","updated_at":"2025-08-02T12:36:22.776Z","avatar_url":"https://github.com/cameronking4.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Azure OpenAI Responses API\n\nA FastAPI application that provides various endpoints for interacting with Azure OpenAI's services, including text completion, conversation, image analysis, and more.\n\n## Features\n\n- Basic text completion\n- Conversation handling\n- Image analysis (base64 and URL)\n- Weather function calling\n- Streaming responses (SSE and async)\n- File search with vector store\n- Structured output with JSON schema\n\n## Prerequisites\n\n- Python 3.9+\n- Azure OpenAI API access\n- Azure OpenAI model deployment\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/yourusername/Responses-API.git\ncd Responses-API\n```\n\n2. Create and activate a virtual environment:\n```bash\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n```\n\n3. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n4. Set up environment variables:\n```bash\ncp .env.sample .env\n```\nEdit `.env` with your Azure OpenAI credentials:\n```\nAZURE_OPENAI_API_MODEL=your-model-deployment-name\nAZURE_OPENAI_API_KEY=your-api-key\nAZURE_OPENAI_API_ENDPOINT=https://your-resource-name.openai.azure.com/\nAZURE_OPENAI_API_VERSION=2025-03-01-preview\n```\n\n## Running the Server\n\n```bash\npython main.py\n```\n\nThe server will start at `http://localhost:8000`. Access the interactive API documentation at `http://localhost:8000/docs`.\n\n## API Endpoints\n\n### Basic Endpoints\n\n#### POST /basic\nBasic text completion endpoint.\n```json\n{\n    \"prompt\": \"Complete this sentence: The quick brown fox\"\n}\n```\n\n#### POST /conversation\nConversation completion with message history.\n```json\n{\n    \"messages\": [\n        {\"role\": \"user\", \"content\": \"What is the capital of France?\"}\n    ]\n}\n```\n\n#### POST /image\nImage analysis with base64-encoded image.\n```json\n{\n    \"prompt\": \"Describe this image\",\n    \"image\": \"base64_encoded_image_data\"\n}\n```\n\n#### POST /image-url\nImage analysis with URL.\n```json\n{\n    \"prompt\": \"Describe this image\",\n    \"url\": \"https://example.com/image.jpg\"\n}\n```\n\n#### POST /weather\nWeather information using function calling.\n```json\n{\n    \"location\": \"London\",\n    \"unit\": \"celsius\"\n}\n```\n\n### Streaming Endpoints\n\n#### POST /stream\nBasic streaming response.\n```json\n{\n    \"prompt\": \"Write a story about\"\n}\n```\n\n#### POST /stream-sse\nServer-Sent Events streaming.\n```json\n{\n    \"prompt\": \"Write a story about\"\n}\n```\n\n#### POST /stream-async\nAsynchronous streaming response.\n```json\n{\n    \"prompt\": \"Write a story about\"\n}\n```\n\n#### POST /conversation-stream\nStreaming conversation response.\n```json\n{\n    \"messages\": [\n        {\"role\": \"user\", \"content\": \"Tell me a story\"}\n    ]\n}\n```\n\n### Chained Response Endpoints\n\n#### POST /chained-response\nResponse chaining using previous_response_id.\n```json\n{\n    \"input\": \"Explain this at a level that could be understood by a college freshman\",\n    \"previous_response_id\": \"resp_67cbc9705fc08190bbe455c5ba3d6daf\"\n}\n```\n\nResponse:\n```json\n{\n    \"response_id\": \"resp_67cbc970fd0881908353a4298996b3f6\",\n    \"response\": \"Here's a simpler explanation...\"\n}\n```\n\n#### POST /manual-chain\nManual response chaining using message history.\n```json\n{\n    \"inputs\": [\n        {\n            \"role\": \"user\",\n            \"content\": \"Define and explain the concept of catastrophic forgetting?\"\n        },\n        {\n            \"role\": \"assistant\",\n            \"content\": \"Catastrophic forgetting refers to...\"\n        },\n        {\n            \"role\": \"user\",\n            \"content\": \"Explain this at a level that could be understood by a college freshman\"\n        }\n    ]\n}\n```\n\nResponse:\n```json\n{\n    \"response_id\": \"resp_67cbc970fd0881908353a4298996b3f6\",\n    \"response\": \"Let me explain it simply...\",\n    \"full_message_history\": [\n        // Previous messages plus the new response\n    ]\n}\n```\n\nImplementation Notes for Chained Responses:\n- Use `/chained-response` when you want to:\n  - Keep the context lightweight\n  - Don't need to modify previous messages\n  - Have a simple request/response flow\n- Use `/manual-chain` when you want to:\n  - Have full control over the message history\n  - Modify or filter previous messages\n  - Keep track of the full conversation history\n\nExample Usage:\n```python\n# First request to get initial response\nresponse1 = requests.post(\n    \"https://api.example.com/chained-response\",\n    json={\"input\": \"Define quantum computing\"}\n)\nfirst_response = response1.json()\n\n# Second request using previous response ID\nresponse2 = requests.post(\n    \"https://api.example.com/chained-response\",\n    json={\n        \"input\": \"Explain it more simply\",\n        \"previous_response_id\": first_response[\"response_id\"]\n    }\n)\n```\n\n### Specialized Endpoints\n\n#### POST /filesearch\nVector store-based file search for smaller files.\n```json\n{\n    \"query\": \"What are the company values?\",\n    \"file_paths\": [\"document1.pdf\", \"document2.pdf\"],\n    \"max_results\": 20,\n    \"chunk_size\": 1048576  // Optional, default 1MB\n}\n```\n\nResponse:\n```json\n{\n    \"response\": \"Based on the documents, the company values include...\"\n}\n```\n\n#### POST /large-filesearch\nChunked processing for large files with progress tracking.\n```json\n{\n    \"query\": \"What are the company policies?\",\n    \"file_paths\": [\"large_handbook.pdf\"],\n    \"max_results\": 5,\n    \"chunk_size\": 524288,    // Optional, default 1MB (1024 * 1024)\n    \"batch_size\": 2          // Optional, default 5 chunks per batch\n}\n```\n\nResponse:\n```json\n{\n    \"search_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n    \"status\": \"completed\",\n    \"response\": \"Summary of company policies found in the document...\"\n}\n```\n\n#### GET /large-filesearch/{search_id}/progress\nTrack progress of large file processing.\n\nResponse:\n```json\n{\n    \"search_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n    \"status\": \"processing\",\n    \"progress_percentage\": 45.5,\n    \"processed_chunks\": 5,\n    \"total_chunks\": 11\n}\n```\n\nImplementation Notes:\n- Status values: \"initializing\", \"processing\", \"completed\", \"failed\"\n- Progress tracking is maintained server-side\n- Files are processed in chunks to manage memory\n- Results are automatically summarized\n\n#### POST /structured\nStructured output with JSON schema validation.\n```json\n{\n    \"input\": \"Extract event: Meeting with John on Monday at 2 PM\",\n    \"json_schema\": {\n        \"type\": \"object\",\n        \"properties\": {\n            \"event\": {\"type\": \"string\"},\n            \"person\": {\"type\": \"string\"},\n            \"day\": {\"type\": \"string\"},\n            \"time\": {\"type\": \"string\"}\n        }\n    }\n}\n```\n\n## Error Handling\n\nAll endpoints include proper error handling and will return appropriate HTTP status codes:\n\n- 200: Successful response\n- 400: Bad request (invalid input)\n- 404: Resource not found (invalid search_id)\n- 500: Server error (Azure OpenAI API issues)\n\n## Implementation Guidelines\n\n### File Processing\n- Use `/filesearch` for files \u003c 1MB\n- Use `/large-filesearch` for files \u003e 1MB\n- Monitor progress using the `/large-filesearch/{search_id}/progress` endpoint\n- Consider batch_size based on your server's capabilities:\n  - Lower batch_size (1-2): Less memory usage, slower processing\n  - Higher batch_size (5-10): More memory usage, faster processing\n\n### Best Practices\n1. File Size Handling:\n   ```python\n   # Check file size before processing\n   file_size = os.path.getsize(file_path)\n   if file_size \u003e 1024 * 1024:  # 1MB\n       use_large_filesearch = True\n   ```\n\n2. Progress Monitoring:\n   ```python\n   # JavaScript example\n   async function monitorProgress(searchId) {\n     while (true) {\n       const response = await fetch(`/large-filesearch/${searchId}/progress`);\n       const progress = await response.json();\n       \n       if (progress.status === 'completed' || progress.status === 'failed') {\n         break;\n       }\n       \n       console.log(`Progress: ${progress.progress_percentage}%`);\n       await new Promise(resolve =\u003e setTimeout(resolve, 1000));\n     }\n   }\n   ```\n\n3. Error Handling:\n   ```python\n   try:\n       response = await fetch('/large-filesearch', {\n           method: 'POST',\n           headers: { 'Content-Type': 'application/json' },\n           body: JSON.stringify({\n               query: \"search query\",\n               file_paths: [\"large_file.pdf\"],\n               chunk_size: 524288,\n               batch_size: 2\n           })\n       });\n       \n       if (!response.ok) {\n           const error = await response.json();\n           console.error(`Error: ${error.detail}`);\n       }\n   } catch (error) {\n       console.error('Network error:', error);\n   }\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](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcameronking4%2Fazure-openai-responses-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcameronking4%2Fazure-openai-responses-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcameronking4%2Fazure-openai-responses-api/lists"}