### Install from wheel Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Installs the package using a local wheel file. ```sh $ pip install ./path-to-wheel-file.whl ``` -------------------------------- ### Install from git Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Installs the package directly from the remote repository. ```sh $ pip install git+ssh://git@github.com/Alchemyst-ai/alchemyst-sdk-python.git ``` -------------------------------- ### Execute example script Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Sets permissions and runs a custom example script. ```sh $ chmod +x examples/.py # run the example against your api $ ./examples/.py ``` -------------------------------- ### Define example script header Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Shebang line for executable example scripts. ```py # add an example to examples/.py #!/usr/bin/env -S rye run python … ``` -------------------------------- ### Install the Alchemyst AI library Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Use pip to install the package from PyPI. ```sh # install from PyPI pip install alchemystai ``` -------------------------------- ### Run mock server Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Starts a Prism mock server for testing against the OpenAPI specification. ```sh # you will need npm installed $ npx prism mock path/to/your/openapi.yml ``` -------------------------------- ### Install aiohttp dependency Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Command to install the SDK with aiohttp support for enhanced concurrency. ```sh # install from PyPI pip install alchemystai[aiohttp] ``` -------------------------------- ### Install dependencies with pip Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Installs development dependencies using the lock file without Rye. ```sh $ pip install -r requirements-dev.lock ``` -------------------------------- ### GET /api/v1/context/traces Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Lists context traces. ```APIDOC ## GET /api/v1/context/traces ### Description Retrieves a list of context traces. ### Method GET ### Endpoint /api/v1/context/traces ### Response #### Success Response (200) - **TraceListResponse** (object) - The response object containing the list of traces. ``` -------------------------------- ### GET /api/v1/context/view Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Retrieves a view. ```APIDOC ## GET /api/v1/context/view ### Description Retrieves a specific view. ### Method GET ### Endpoint /api/v1/context/view ### Response #### Success Response (200) - **ViewRetrieveResponse** (object) - The response object containing the view data. ``` -------------------------------- ### GET /api/v1/context/view/docs Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Retrieves documentation for a view. ```APIDOC ## GET /api/v1/context/view/docs ### Description Retrieves documentation associated with a view. ### Method GET ### Endpoint /api/v1/context/view/docs ### Response #### Success Response (200) - **ViewDocsResponse** (object) - The response object containing the documentation. ``` -------------------------------- ### Determine installed library version Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Access the __version__ attribute to verify which version of the SDK is currently active in the environment. ```python import alchemyst_ai print(alchemyst_ai.__version__) ``` -------------------------------- ### GET /api/v1/context/add-async/status Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Lists the status of multiple asynchronous context tasks. ```APIDOC ## GET /api/v1/context/add-async/status ### Description Retrieves a list of statuses for asynchronous context tasks based on provided query parameters. ### Method GET ### Endpoint /api/v1/context/add-async/status ### Response #### Success Response (200) - **StatusListResponse** (object) - The response object containing a list of task statuses. ``` -------------------------------- ### GET /api/v1/context/add-async/{id}/status Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Retrieves the status of a specific asynchronous context task. ```APIDOC ## GET /api/v1/context/add-async/{id}/status ### Description Retrieves the current status of an asynchronous context task by its ID. ### Method GET ### Endpoint /api/v1/context/add-async/{id}/status ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the task. ### Response #### Success Response (200) - **StatusRetrieveResponse** (object) - The response object containing the status of the task. ``` -------------------------------- ### Initialize and use AsyncAlchemystAI Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Demonstrates importing the asynchronous client and performing an API call using await. ```python import os import asyncio from alchemyst_ai import AsyncAlchemystAI client = AsyncAlchemystAI( api_key=os.environ.get("ALCHEMYST_AI_API_KEY"), # This is the default and can be omitted ) async def main() -> None: response = await client.v1.context.add( context_type="resource", documents=[{"content": "The content of the document"}], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) print(response.context_id) asyncio.run(main()) ``` -------------------------------- ### Configure AsyncAlchemystAI with aiohttp Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Shows how to instantiate the client using the DefaultAioHttpClient for the HTTP backend. ```python import os import asyncio from alchemyst_ai import DefaultAioHttpClient from alchemyst_ai import AsyncAlchemystAI async def main() -> None: async with AsyncAlchemystAI( api_key=os.environ.get("ALCHEMYST_AI_API_KEY"), # This is the default and can be omitted http_client=DefaultAioHttpClient(), ) as client: response = await client.v1.context.add( context_type="resource", documents=[{"content": "The content of the document"}], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) print(response.context_id) asyncio.run(main()) ``` -------------------------------- ### Bootstrap development environment with Rye Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Initializes the project environment using the bootstrap script. ```sh $ ./scripts/bootstrap ``` -------------------------------- ### Initialize client and add context Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Initialize the AlchemystAI client using an API key from environment variables and perform a context addition request. ```python import os from alchemyst_ai import AlchemystAI client = AlchemystAI( api_key=os.environ.get("ALCHEMYST_AI_API_KEY"), # This is the default and can be omitted ) response = client.v1.context.add( context_type="resource", documents=[{"content": "The content of the document"}], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) print(response.context_id) ``` -------------------------------- ### Run test suite Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Executes the project test suite. ```sh $ ./scripts/test ``` -------------------------------- ### Configure HTTP client with custom settings Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Override the default httpx client during initialization to support proxies and custom transports. ```python import httpx from alchemyst_ai import AlchemystAI, DefaultHttpxClient client = AlchemystAI( # Or use the `ALCHEMYST_AI_BASE_URL` env var base_url="http://my.test.server.example.com:8083", http_client=DefaultHttpxClient( proxy="http://my.test.proxy.example.com", transport=httpx.HTTPTransport(local_address="0.0.0.0"), ), ) ``` -------------------------------- ### Add context with nested parameters Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Demonstrates how to use the client to add context with nested metadata parameters. ```python from alchemyst_ai import AlchemystAI client = AlchemystAI() response = client.v1.context.add( context_type="resource", documents=[{}], scope="internal", source="support-inbox", metadata={ "file_name": "support_thread_TCK-1234.txt", "file_size": 2048, "file_type": "text/plain", "group_name": ["support", "pricing"], "last_modified": "2025-01-10T12:34:56.000Z", }, ) print(response.metadata) ``` -------------------------------- ### Customize client per-request Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Use the with_options method to apply custom HTTP client configurations for specific requests. ```python client.with_options(http_client=DefaultHttpxClient(...)) ``` -------------------------------- ### POST /api/v1/context/add-async Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Creates a new asynchronous context task. ```APIDOC ## POST /api/v1/context/add-async ### Description Creates a new asynchronous context task using the provided parameters. ### Method POST ### Endpoint /api/v1/context/add-async ### Response #### Success Response (200) - **AddAsyncCreateResponse** (object) - The response object containing details of the created task. ``` -------------------------------- ### POST /api/v1/context/add Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Adds a new context entry. ```APIDOC ## POST /api/v1/context/add ### Description Adds a new context entry to the system. ### Method POST ### Endpoint /api/v1/context/add ### Response #### Success Response (200) - **ContextAddResponse** (object) - The response object containing details of the added context. ``` -------------------------------- ### POST /api/v1/context/memory/add Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Adds memory. ```APIDOC ## POST /api/v1/context/memory/add ### Description Adds a new memory entry. ### Method POST ### Endpoint /api/v1/context/memory/add ### Response #### Success Response (200) - **MemoryAddResponse** (object) - The response object containing the added memory details. ``` -------------------------------- ### Sync dependencies with Rye Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Manually synchronizes all project dependencies. ```sh $ rye sync --all-features ``` -------------------------------- ### Build package distribution Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Generates distribution files in the dist directory. ```sh $ rye build # or $ python -m build ``` -------------------------------- ### Activate virtual environment Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Activates the Rye-managed virtual environment to run scripts directly. ```sh # Activate the virtual environment - https://docs.python.org/3/library/venv.html#how-venvs-work $ source .venv/bin/activate # now you can omit the `rye run` prefix $ python script.py ``` -------------------------------- ### Manage HTTP client lifecycle with context manager Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Use a context manager to ensure the HTTP client is closed automatically after requests are completed. ```python from alchemyst_ai import AlchemystAI with AlchemystAI() as client: # make requests here ... # HTTP client is now closed ``` -------------------------------- ### client.v1.context.add Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Adds a new context resource to the Alchemyst platform. ```APIDOC ## client.v1.context.add ### Description Adds a new context resource to the system. This method requires specifying the context type, documents, scope, source, and metadata. ### Parameters - **context_type** (string) - Required - The type of context being added (e.g., "resource"). - **documents** (list) - Required - A list of document objects. - **scope** (string) - Required - The scope of the context (e.g., "internal"). - **source** (string) - Required - The source identifier for the context. - **metadata** (dict) - Optional - Additional metadata including file_name, file_size, file_type, group_name, and last_modified. ### Request Example ```python client.v1.context.add( context_type="resource", documents=[{"content": "The content of the document"}], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) ``` ``` -------------------------------- ### Import Org Context View Response Type Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Import the ContextViewResponse type for use with organization context operations. ```python from alchemyst_ai.types.v1.org import ContextViewResponse ``` -------------------------------- ### Enable SDK Logging Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Set the ALCHEMYST_AI_LOG environment variable to control logging verbosity. ```shell $ export ALCHEMYST_AI_LOG=info ``` -------------------------------- ### POST /api/v1/context/memory/update Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Updates memory. ```APIDOC ## POST /api/v1/context/memory/update ### Description Updates existing memory entries. ### Method POST ### Endpoint /api/v1/context/memory/update ### Response #### Success Response (200) - **MemoryUpdateResponse** (object) - The response object confirming the update. ``` -------------------------------- ### client.v1.org.context.view Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Retrieves the organization context view using the provided parameters. ```APIDOC ## POST /api/v1/org/context/view ### Description Retrieves the organization context view. ### Method POST ### Endpoint /api/v1/org/context/view ### Parameters - **params** (ContextViewParams) - Required - The parameters required to view the organization context. ### Response - **response** (ContextViewResponse) - The organization context view data. ``` -------------------------------- ### Import AddAsync Types Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Required imports for handling AddAsync response objects. ```python from alchemyst_ai.types.v1.context import AddAsyncCreateResponse, AddAsyncCancelResponse ``` -------------------------------- ### Import Context Types Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Required imports for handling context-related API responses. ```python from alchemyst_ai.types.v1 import ContextAddResponse, ContextSearchResponse ``` -------------------------------- ### Configure request timeouts Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Sets request timeouts globally or per-request using float values or httpx.Timeout objects. ```python from alchemyst_ai import AlchemystAI # Configure the default for all requests: client = AlchemystAI( # 20 seconds (default is 1 minute) timeout=20.0, ) # More granular control: client = AlchemystAI( timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0), ) # Override per-request: client.with_options(timeout=5.0).v1.context.add( context_type="resource", documents=[{"content": "The content of the document"}], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) ``` -------------------------------- ### POST /api/v1/context/search Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Searches for context entries. ```APIDOC ## POST /api/v1/context/search ### Description Searches for context entries based on provided criteria. ### Method POST ### Endpoint /api/v1/context/search ### Response #### Success Response (200) - **ContextSearchResponse** (object) - The response object containing search results. ``` -------------------------------- ### Lint code Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Runs the linting tools to check code quality. ```sh $ ./scripts/lint ``` -------------------------------- ### POST /api/v1/context/memory/delete Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Deletes memory. ```APIDOC ## POST /api/v1/context/memory/delete ### Description Deletes memory entries. ### Method POST ### Endpoint /api/v1/context/memory/delete ``` -------------------------------- ### Handle API errors Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Shows how to catch and handle specific API exceptions including connection issues, rate limits, and status errors. ```python import alchemyst_ai from alchemyst_ai import AlchemystAI client = AlchemystAI() try: client.v1.context.add( context_type="resource", documents=[{"content": "The content of the document"}], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) except alchemyst_ai.APIConnectionError as e: print("The server could not be reached") print(e.__cause__) # an underlying Exception, likely raised within httpx. except alchemyst_ai.RateLimitError as e: print("A 429 status code was received; we should back off a bit.") except alchemyst_ai.APIStatusError as e: print("Another non-200-range status code was received") print(e.status_code) print(e.response) ``` -------------------------------- ### Import View Types Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Required imports for handling view-related API responses. ```python from alchemyst_ai.types.v1.context import ViewRetrieveResponse, ViewDocsResponse ``` -------------------------------- ### Format code Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/CONTRIBUTING.md Automatically formats code and fixes linting issues. ```sh $ ./scripts/format ``` -------------------------------- ### Import Trace Types Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Required imports for handling trace-related API responses. ```python from alchemyst_ai.types.v1.context import TraceListResponse, TraceDeleteResponse ``` -------------------------------- ### Make Undocumented Requests Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Use standard HTTP verbs on the client instance to access undocumented endpoints while maintaining client configuration. ```python import httpx response = client.post( "/foo", cast_to=httpx.Response, body={"my_param": True}, ) print(response.headers.get("x-foo")) ``` -------------------------------- ### Configure retry settings Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Configures the number of retries for requests globally or on a per-request basis. ```python from alchemyst_ai import AlchemystAI # Configure the default for all requests: client = AlchemystAI( # default is 2 max_retries=0, ) # Or, configure per-request: client.with_options(max_retries=5).v1.context.add( context_type="resource", documents=[{"content": "The content of the document"}], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) ``` -------------------------------- ### Import Status Types Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Required imports for handling status retrieval and listing response objects. ```python from alchemyst_ai.types.v1.context.add_async import StatusRetrieveResponse, StatusListResponse ``` -------------------------------- ### POST /api/v1/context/delete Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Deletes a context entry. ```APIDOC ## POST /api/v1/context/delete ### Description Deletes a context entry based on provided parameters. ### Method POST ### Endpoint /api/v1/context/delete ``` -------------------------------- ### Import Memory Types Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Required imports for handling memory-related API responses. ```python from alchemyst_ai.types.v1.context import MemoryUpdateResponse, MemoryAddResponse ``` -------------------------------- ### Stream API Responses Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Use .with_streaming_response within a context manager to process response bodies incrementally. ```python with client.v1.context.with_streaming_response.add( context_type="resource", documents=[{"content": "The content of the document"}], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) as response: print(response.headers.get("X-My-Header")) for line in response.iter_lines(): print(line) ``` -------------------------------- ### Access Raw Response Data Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Prefix an HTTP method call with .with_raw_response to access headers and the underlying response object. ```python from alchemyst_ai import AlchemystAI client = AlchemystAI() response = client.v1.context.with_raw_response.add( context_type="resource", documents=[{ "content": "The content of the document" }], scope="internal", source="platform.api.context.add", metadata={ "file_name": "notes.txt", "file_type": "text/plain", "last_modified": "2025-10-01T18:42:40.419Z", "file_size": 1024, }, ) print(response.headers.get('X-My-Header')) context = response.parse() # get the object that `v1.context.add()` would have returned print(context.context_id) ``` -------------------------------- ### DELETE /api/v1/context/add-async/{id}/cancel Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Cancels an existing asynchronous context task by its ID. ```APIDOC ## DELETE /api/v1/context/add-async/{id}/cancel ### Description Cancels a specific asynchronous context task identified by the provided ID. ### Method DELETE ### Endpoint /api/v1/context/add-async/{id}/cancel ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the task to cancel. ### Response #### Success Response (200) - **AddAsyncCancelResponse** (object) - The response object confirming the cancellation. ``` -------------------------------- ### DELETE /api/v1/context/traces/{traceId}/delete Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/api.md Deletes a specific context trace. ```APIDOC ## DELETE /api/v1/context/traces/{traceId}/delete ### Description Deletes a specific trace by its ID. ### Method DELETE ### Endpoint /api/v1/context/traces/{traceId}/delete ### Parameters #### Path Parameters - **traceId** (string) - Required - The unique identifier of the trace to delete. ### Response #### Success Response (200) - **TraceDeleteResponse** (object) - The response object confirming deletion. ``` -------------------------------- ### Differentiate Null and Missing Fields Source: https://github.com/alchemyst-ai/alchemyst-sdk-python/blob/main/README.md Use model_fields_set to determine if a field is explicitly null or missing from the API response. ```python if response.my_field is None: if 'my_field' not in response.model_fields_set: print('Got json like {}, without a "my_field" key present at all.') else: print('Got json like {"my_field": null}.') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.