> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.alfa.boosted.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.alfa.boosted.ai/_mcp/server.

# Fetching Thread Artifacts

> Learn how to fetch tables and graphs inside threads.

In certain cases, Alfa will produce a table or graph in its answer. These artifacts will be included in messages as JSON wrapped in markdown code blocks (triple backticks).

````
This is an artifact in a message:
```{"type": "output_artifact", "artifact_id": "..."}```
Text in a message can come before or after the object.
````

### Extracting Artifact ID's

In order to fetch the contents of these artifacts, the artifact ID's must be extracted:

````python
import re


def extract_artifact_ids_from_message(message: str) -> list[str]:
    regex = r"""```[\s\S]*?\"artifact_id\"\s*:\s*\"([^\"]+)\"[\s\S]*?```"""
    return re.findall(regex, message)
````

### Fetching Artifacts

```python
def get_thread_artifact(thread_id: str, artifact_id: str):
    """
    Get a thread artifact (table or graph).
    """
    url = f"{BASE_URL}/v2/thread/{thread_id}/artifact/{artifact_id}"

    response = requests.get(url, headers=headers)

    if response.status_code == 200:
        data = response.json()
        print("Got artifact")
        print(data["artifact"])
    else:
        print(f"Error: {response.status_code}, {response.text}")
```