{"library":"metaphor-python","title":"Metaphor Python API Client","description":"Metaphor-python is a Python client library for interacting with the Metaphor API, a search engine optimized for Large Language Models (LLMs). It enables neural search and content retrieval, providing clean HTML content from search results. The library is currently at version 0.1.23 and is under active development, indicated by its 'Alpha' status on PyPI. While no explicit release cadence is documented, updates are released as new features and improvements to the Metaphor API are made available.","language":"python","status":"active","last_verified":"Thu Apr 16","install":{"commands":["pip install metaphor-python"],"cli":null},"imports":["from metaphor_python import Metaphor"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom metaphor_python import Metaphor\n\n# Ensure your Metaphor API key is set as an environment variable\n# e.g., export METAPHOR_API_KEY=\"your_metaphor_api_key_here\"\napi_key = os.environ.get('METAPHOR_API_KEY')\n\nif not api_key:\n    print(\"Error: METAPHOR_API_KEY environment variable not set.\")\nelse:\n    try:\n        metaphor = Metaphor(api_key=api_key)\n        # Perform a search\n        results = metaphor.search(\"latest developments in AI agents\", num_results=3, use_autoprompt=True)\n\n        if results.contents:\n            print(\"Search Results:\")\n            for i, item in enumerate(results.contents):\n                print(f\"---\\nResult {i+1}:\\nTitle: {item.title}\\nURL: {item.url}\\nExtract: {item.extract[:200]}...\")\n        else:\n            print(\"No search results found.\")\n\n    except Exception as e:\n        print(f\"An error occurred: {e}\")","lang":"python","description":"Initializes the Metaphor client using an API key from an environment variable and performs a basic search query, printing the title, URL, and a snippet of the content for the top results.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}