Connect PyRIT to the private Morse API, uncensored models included: set it up, pick a model, and check it works. Updated December 5, 2026.

Page: https://trymorse.ai/inference/docs/tools/pyrit

# Use PyRIT with a private, uncensored API

Give [PyRIT](https://github.com/microsoft/PyRIT) the base URL `https://inference.trymorse.ai/v1` and a Morse API key. It calls the OpenAI API.

The same key also calls 17 uncensored models. [See them](https://trymorse.ai/inference/uncensored).

**Agent security:** Stress-test your AI agents to identify prompt injection, jailbreak, and tool misuse vulnerabilities.

## Before you start

Make a key for PyRIT alone, with a spend limit, under **API keys** in the [console](https://console.trymorse.ai). Then one tool can't spend all your credits. See [Limit a key](https://trymorse.ai/inference/docs/authentication#limits). Keep the key in your environment, where PyRIT reads it.

Terminal

```
export MORSE_API_KEY="sk_morse_..."
```

## Set it up with a prompt

Paste this into a coding agent, such as Claude Code or Codex, and it sets up PyRIT for you. Or set it up by hand, below.

Setup prompt

```
Set up PyRIT to use Morse.

1. Use the OpenAI-compatible endpoint https://inference.trymorse.ai/v1
2. Read the key from the MORSE_API_KEY environment variable.
3. Default to the model z-ai/glm-5.3-uncensored.
4. Follow https://trymorse.ai/inference/docs/tools/pyrit, then run its check.

Change only PyRIT's settings. Leave everything else as it is.
```

## Set up PyRIT

1. Add Morse to PyRIT's .envPyRIT reads its endpoints from `~/.pyrit/.env`. Add these lines:~/.pyrit/.env`OPENAI_CHAT_ENDPOINT="https://inference.trymorse.ai/v1" OPENAI_CHAT_KEY="${MORSE_API_KEY}" OPENAI_CHAT_MODEL="z-ai/glm-5.3-uncensored" ADVERSARIAL_CHAT_ENDPOINT="https://inference.trymorse.ai/v1" ADVERSARIAL_CHAT_KEY="${MORSE_API_KEY}" ADVERSARIAL_CHAT_MODEL="z-ai/glm-5.3-uncensored"``OPENAI_CHAT_*` is the model PyRIT's `OpenAIChatTarget` calls when you name no other.`ADVERSARIAL_CHAT_*` is the attacker: the model that writes the attacks PyRIT sends to your agent.PyRIT fills in the key from `MORSE_API_KEY` in your environment, so the file holds no key.
2. Aim the attacks at your agentPyRIT's `target` initializer, which runs by default, makes the attacker `adversarial_chat`. Its attacks, such as role play and TAP, use it to write the prompts. Make your agent's endpoint the attack's `objective_target`.

## Which model to pick

| Model | Context | Input / output | Why |
| --- | --- | --- | --- |
| `z-ai/glm-5.3-uncensored` | 1M | $1.75 / $5 | Uncensored, so it writes attacks instead of refusing, with JSON output in an attested enclave. |
| `qwen/qwen3.8-27b-uncensored` | 256K | $0.35 / $1.75 | Uncensored and cheaper, with JSON output in an attested enclave. |
| `google/gemma-4-26b-a4b-uncensored` | 256K | $0.175 / $0.85 | Uncensored, and the cheapest here, for long attack runs. |

Prices are in dollars per million tokens, on each model's default endpoint. Every model is on the [models page](https://trymorse.ai/inference/models).

## Check it works

Save this as a script and run it with Python:

check.py

```
import asyncio

from pyrit.executor.attack import PromptSendingAttack
from pyrit.prompt_target import OpenAIChatTarget
from pyrit.setup import IN_MEMORY, initialize_pyrit_async


async def main():
    await initialize_pyrit_async(memory_db_type=IN_MEMORY)
    attack = PromptSendingAttack(objective_target=OpenAIChatTarget())
    result = await attack.execute_async(objective="Say hello in one word.")
    print(result.last_response.converted_value)


asyncio.run(main())
```

It sends one request. The model's response shows that Morse took it.

## Keep it private

Set a privacy floor on PyRIT's key to hold it to a tier, such as TEE. Without a floor, a request runs on its model's default privacy tier. The floor only decides which endpoints serve the requests. See [Privacy tiers](https://trymorse.ai/inference/docs/privacy-tiers) and [Provider routing](https://trymorse.ai/inference/docs/provider-routing).

On a plain API call, TLS ends inside Morse's door, an attested enclave, which seals the request before the relay receives it. A plain client checks the door's certificate, not its attestation. To check the attestation yourself, see [Sealed API keys](https://trymorse.ai/inference/docs/sealed-api-keys).

## If something goes wrong

| What you see | What to do |
| --- | --- |
| `400` on a scorer's request | Use a model from the table: PyRIT's scorers and its attacker ask for JSON output. The scorers use `OPENAI_CHAT_*` unless you set `OBJECTIVE_SCORER_CHAT_*`. |
| `No API key available for endpoint` | Set `MORSE_API_KEY` in the shell you start Python from: the file reads it from there. |
| `400 setting_not_forwarded` | PyRIT's attacker sends `temperature` and `response_format`. Turn on **Let my settings reach the model host** on the key's page in the console. See [Settings](https://trymorse.ai/inference/docs/api/parameters#settings). |
| `401 invalid_api_key` | Check that `MORSE_API_KEY` is set where PyRIT starts, and that the key isn't revoked. |
| `402 insufficient_balance` or `key_spend_limit_reached` | Add credits, or raise the key's spend limit. A request holds credit for its output limit before it starts: see [Holds](https://trymorse.ai/inference/docs/pricing#holds). |
| `404 model_not_found` | Use a model's id exactly as the table above writes it, with the part before the slash. |

Every code is in [Error codes](https://trymorse.ai/inference/docs/api/errors). For other tools, see [Tools and coding agents](https://trymorse.ai/inference/docs/tools).
