--- title: Address Detection and Summarization API emoji: 🏠📝 colorFrom: blue colorTo: green sdk: docker app_port: 7860 pinned: false license: mit --- # Address Detection and Summarization API A FastAPI service that provides two main endpoints for AI-powered text processing: ## 🚀 Features - 🏠 **Address Detection**: Extracts and formats addresses from unstructured text - 📝 **Text Summarization**: Creates concise summaries with sentiment analysis - 🤖 **OpenAI Integration**: Uses GPT-4 for natural language processing - 🔐 **Secure**: API key required via `x-api-key` header - 📊 **Sentiment Analysis**: Returns sentiment label and score (-1.0 to 1.0) ## 📋 API Endpoints ### Root & Health - `GET /` - API information - `GET /health` - Health check - `GET /docs` - Interactive API documentation ### Address Detection `POST /address-detection` Extract addresses from text content. **Request:** ```json { "entity_urn": "unique_id", "content": "Please send to 123 Main Street, New York, NY 10001" } ``` **Headers:** ``` Content-Type: application/json x-api-key: your_openai_api_key ``` ### Text Summarization `POST /summarize` Generate summary with sentiment analysis. **Request:** ```json { "entity_urn": "unique_id", "content": "Your text content to summarize..." } ``` ## 🔧 Usage Examples ### Using curl: ```bash # Address Detection curl -X POST "https://your-space-name.hf.space/address-detection" \ -H "Content-Type: application/json" \ -H "x-api-key: your_openai_api_key" \ -d '{"entity_urn": "test", "content": "Send to 123 Main St, NYC"}' # Summarization curl -X POST "https://your-space-name.hf.space/summarize" \ -H "Content-Type: application/json" \ -H "x-api-key: your_openai_api_key" \ -d '{"entity_urn": "test", "content": "I love this product!"}' ``` ### Response Format: ```json { "message": "success", "result": "extracted_addresses || separated", "action_type": "detect_address", "entity_urn": "test", "sentiment": null } ``` For summarization, `sentiment` contains: ```json { "label": "positive", "score": 0.8 } ``` ## 🔑 Authentication You need an OpenAI API key to use this service: 1. Get your API key from [OpenAI Platform](https://platform.openai.com/) 2. Include it in the `x-api-key` header with each request 3. No registration required - just use your own key ## 🏗️ Built With - **FastAPI** 0.115.14 - Modern web framework - **OpenAI** 1.92.1 - AI language models - **Pydantic** 2.11.7 - Data validation - **Python** 3.12 - Runtime ## 📖 Documentation Visit `/docs` for interactive API documentation with request/response examples and testing interface. ## 🔒 Security & Privacy - Your OpenAI API key is required for each request - No API keys are stored on our servers - All requests are processed in real-time - No conversation history is retained