Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/platforms/python/agent-tracing/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Pick your AI stack. Each page has install and verify details.
{to: "/agent-tracing/pydantic-ai/", title: "Pydantic AI", icon: "pydantic-ai"},
{to: "/agent-tracing/huggingface_hub/", title: "Hugging Face Hub", icon: "huggingface_hub"},
{to: "/agent-tracing/mistral/", title: "Mistral", icon: "mistral"},
{to: "/agent-tracing/typesafe/", title: "TypeSafe AI", icon: "typesafe-ai"},
]}
/>

Expand Down
85 changes: 85 additions & 0 deletions docs/platforms/python/agent-tracing/typesafe/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: TypeSafe AI
description: "Learn about using Sentry for TypeSafe AI."
sidebar_order: 30
---

This integration connects Sentry with the [TypeSafe Python SDK](https://github.com/typesafe-ai/typesafe-sdk-python).

Once you've installed this SDK, you can use the Sentry Agents Tracing, a Sentry dashboard that helps you understand what's going on with your AI requests.

## Install

Install `sentry-sdk` from PyPI:

```bash {tabTitle:pip}
pip install sentry-sdk
```

```bash {tabTitle:uv}
uv add sentry-sdk
```

## Configure

Add `TypeSafeIntegration()` to your `integrations` list:

```python
import sentry_sdk
from sentry_sdk.integrations.typesafe import TypeSafeIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Add data like inputs and responses;
# see https://docs.sentry.io/platforms/python/data-management/data-collected/ for more info
send_default_pii=True,
integrations=[
TypeSafeIntegration(),
],
)
```

## Verify

Verify that the integration works by making a request to TypeSafe AI.

```python
import sentry_sdk
from sentry_sdk.integrations.typesafe import TypeSafeIntegration

from typesafe_sdk import Choice, TypeSafeClient

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
traces_sample_rate=1.0,
send_default_pii=True,
integrations=[
TypeSafeIntegration(),
],
)

client = TypeSafeClient(api_key="(your TypeSafe key)")

response = client.system_one(
state={"document": "I was charged twice. Please fix this ASAP."},
questions={
"category": Choice(
instructions="What is this ticket about?",
criteria={"billing": None, "technical": None, "other": None},
),
},
)
```

To try the async variant, use `AsyncTypeSafeClient` with `await`.

After running this script, the resulting data should show up in the `AI Spans` tab on the `Explore > Traces > Trace` page on Sentry.io.

It may take a couple of moments for the data to appear in [sentry.io](https://sentry.io).

## Supported Versions

- TypeSafe AI (`typesafe-sdk`): `0.7.0+`
1 change: 1 addition & 0 deletions docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
| <LinkWithPlatformIcon platform="pydantic-ai" label="Pydantic AI" url="/platforms/python/agent-tracing/pydantic-ai" /> | ✓ |
| <LinkWithPlatformIcon platform="python.mistral" label="Mistral" url="/platforms/python/agent-tracing/mistral" /> | |
| <LinkWithPlatformIcon platform="mcp" label="MCP (Model Context Protocol)" url="/platforms/python/integrations/mcp" /> | ✓ |
| <LinkWithPlatformIcon platform="typesafe-ai" label="TypeSafe AI" url="/platforms/python/agent-tracing/typesafe" /> | |


### Data Processing
Expand Down
7 changes: 7 additions & 0 deletions src/components/platformIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
import TornadoSVG from 'platformicons/svg/tornado.svg';
import TracingSVG from 'platformicons/svg/tracing.svg';
import TrytonSVG from 'platformicons/svg/tryton.svg';
import TypeSafeSVG from 'platformicons/svg/typesafe-ai.svg';
import UnitySVG from 'platformicons/svg/unity.svg';
import UnoSVG from 'platformicons/svg/uno.svg';
import UnrealSVG from 'platformicons/svg/unreal.svg';
Expand Down Expand Up @@ -303,6 +304,7 @@
import TornadoSVGLarge from 'platformicons/svg_80x80/tornado.svg';
import TracingSVGLarge from 'platformicons/svg_80x80/tracing.svg';
import TrytonSVGLarge from 'platformicons/svg_80x80/tryton.svg';
import TypeSafeSVGLarge from 'platformicons/svg_80x80/typesafe-ai.svg';
import UnitySVGLarge from 'platformicons/svg_80x80/unity.svg';
import UnoSVGLarge from 'platformicons/svg_80x80/uno.svg';
import UnrealSVGLarge from 'platformicons/svg_80x80/unreal.svg';
Expand Down Expand Up @@ -929,6 +931,10 @@
sm: TrytonSVG,
lg: TrytonSVGLarge,
},
'typesafe-ai': {
sm: TypeSafeSVG,
lg: TypeSafeSVGLarge,
},
unity: {
sm: UnitySVG,
lg: UnitySVGLarge,
Expand Down Expand Up @@ -1181,6 +1187,7 @@
sql: 'sql',
sqlserver: 'sqlserver',
swift: 'swift',
'typesafe-ai': 'typesafe-ai',
unity: 'unity',
// This will be deprecated in favor of 'unrealengine'
ue4: 'unreal',
Expand Down Expand Up @@ -1288,7 +1295,7 @@

if (title) {
return (
<img

Check warning on line 1298 in src/components/platformIcon.tsx

View workflow job for this annotation

GitHub Actions / Lint

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` or a custom image loader to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
src={typeof svg === 'string' ? svg : svg?.src}
width={size}
height={size}
Expand Down
Loading