For the complete documentation index, see llms.txt. This page is also available as Markdown.

Fireworks AI integration

You can integrate Tonic Textual with Fireworks AI to build LLM applications and fine-tuned models on open models without exposing personally identifiable information (PII) or other sensitive data.

Textual detects sensitive values in text, then replaces them with tokens or realistic synthetic values. Fireworks serves and fine-tunes open models behind an OpenAI-compatible API.

This topic explains how Fireworks AI and Textual work together, then walks you through an example where you:

  1. Redact prompts before you send them to a Fireworks model.

  2. Restore the original values in the response.

  3. Control how Textual handles each entity type.

  4. Use synthesized values to de-identify conversations.

  5. Fine-tune a model on the de-identified conversations.

It also explains how to:

  • Use the Textual LangChain integration.

  • Configure Fireworks as the LLM provider for a self-hosted Textual instance.

About Fireworks AI

Fireworks AI is an inference and training platform for open models such as Kimi, DeepSeek, GLM, Qwen, MiniMax, and gpt-oss.

You can either:

  • Call models on shared serverless capacity and pay per token.

  • Run the models on dedicated deployments.

You can also fine-tune models on your own data and serve the tuned model on the same platform.

Because the Fireworks API is compatible with the OpenAI API, you point the official OpenAI client libraries at the Fireworks base URL, https://api.fireworks.ai/inference/v1.

Frameworks that support OpenAI-compatible providers, such as LangChain, work the same way.

For more information, go to:

How Textual works with Fireworks

Textual can work with Fireworks in the following ways:

Prompt redaction

Before a prompt leaves your environment, Textual replaces names, contact details, account numbers, and other sensitive values with tokens.

It then restores the original values in the model's response.

Training data de-identification

Textual replaces sensitive values in conversations, tickets, and documents with realistic synthetic values.

You can then fine-tune a model on the data without the model learning real PII.

LLM-powered features

For features that require an LLM, self-hosted Textual instances can, through the Textual OpenAI-compatible provider, use a Fireworks model.

The integration involves the following tasks:

Task
Fireworks AI
Tonic Textual

Detection

Not involved

Detects sensitive values, then labels each one with an entity type, such as NAME_GIVEN or EMAIL_ADDRESS.

Redaction

Generates a response from the redacted prompt.

Keeps the tokens in its output.

Replaces each value with a token, such as [NAME_GIVEN_dySb5].

Uses unredact to restore the original values.

Synthesis

Not involved.

Replaces each value with a realistic synthetic value of the same type.

Fine-tuning

Trains a LoRA adapter on the de-identified dataset.

Serves the tuned model.

De-identifies the exported source records as training data.

Example: Build a privacy-safe support assistant

In this example:

  1. You use a Fireworks model to draft replies to customer support messages.

  2. Textual redacts each message before it reaches the model.

  3. Textual then restores the customer's details in the reply.

  4. You de-identify past support conversations.

  5. You fine-tune a model on those conversations.

Supported models for the example

The example can work with the following serverless models. Each of these models keeps Textual tokens intact when the system prompt asks it to.

For the full list of models, go to the Fireworks model library.

Model type
Model identifier
Notes

Chat

accounts/fireworks/models/gpt-oss-120b

Used in the example.

Chat

accounts/fireworks/models/kimi-k3

accounts/fireworks/models/glm-5p3

accounts/fireworks/models/deepseek-v4p1-flash

accounts/fireworks/models/minimax-m3

Use any of these in place of the gpt-oss-120b model.

Base model for fine-tuning

accounts/fireworks/models/qwen3-8b

Used as the base model for fine-tuning in this example.

For other base models, go to Fine-tuning models.

Prerequisites

To complete this tutorial, you must have the following:

  • A Tonic Textual account.

  • A Textual API key. The API key must have permission to redact text strings.

  • A Fireworks AI API key. To create one, in the Fireworks console, go to API Keys.

  • Python 3.9 or later.

Set up the environment

  1. Install the dependencies.

  1. Set the Textual environment variables.

  1. Create a Textual client and a Fireworks client, then choose your model.

TextualNer() connects to Textual Cloud.

On a self-hosted instance, you must pass the instance URL. For example, TextualNer("https://textual.your-company.com").

Redact prompts and restore responses

Next:

  1. Use Textual to redact each customer message.

  2. Send the redacted message to Fireworks.

  3. To restore the original values, call unredact on the response.

The Fireworks model sees only tokens. The customer's name, email address, and telephone number never leave your environment.

The system prompt tells the model to copy tokens exactly. Without this instruction, a model might rewrite a token or drop its brackets, and Textual could not restore the value.

Fireworks receives a message that looks similar to the following:

Choose how Textual handles each entity type

By default, Textual replaces every value that it detects with a token.

To pass some entity types through unchanged, or to replace them with synthetic values, use the generator_config parameter.

The following example keeps dates in the prompt, so that the model can reason about them, but still redacts names and contact details.

The handling options are:

  • Redaction

  • Synthesis

  • GroupingSynthesis

  • ReplacementSynthesis

  • Off

For the list of entity types, see Built-in entity types.

To learn more about the options, see Configure entity type handling for redaction.

De-identify training data and fine-tune a model

Past support conversations are good training data for a support model, but they're full of sensitive customer data.

To fine-tune on them safely, replace the sensitive values with synthetic values. Synthesis keeps the text natural, so that the tuned model learns how to handle names and contact details without learning real ones.

  1. De-identify each conversation, then write it to a JSONL file. Each line must contain a messages array in the chat format. The code sends all the messages of a conversation to Textual in one redact_bulk call. Note that in production, you read the conversations from your support system or data warehouse. To de-identify entire files or datasets, use Textual datasets instead.

  1. Upload the dataset, then start a supervised fine-tuning job with firectl, the Fireworks CLI.

  1. When the job finishes, deploy the tuned model. In the example code, use its model identifier as CHAT_MODEL.

To learn about supported base models, training methods, and deployment options, go to Fine-tuning models.

Use Fireworks with the Textual LangChain integration

If you build with LangChain, use:

The following chain:

  1. Redacts a support ticket.

  2. Summarizes it with a Fireworks model.

  3. Restores the original values in the summary.

Use Fireworks as the LLM provider for self-hosted Textual instances

Some Textual features, such as model-based custom entity types, require a connection to an LLM.

On a self-hosted Textual instance, you can use a Fireworks model through Textual's OpenAI-compatible provider.

In your Textual instance, set the following environment variables, then restart the Textual Worker service.

To verify the connection, check the Textual Worker logs for a message that the client initialized.

Other model and redaction options

Here are some other options to try:

  • To use other Fireworks chat models, change the value of CHAT_MODEL. For more information, go to the Fireworks model library.

  • Use redact_json and redact_html to redact JSON and HTML content, such as tool results in an agent. For more information, go to Redact individual strings.

  • Add Textual custom entity types to detect values that are specific to your business, such as internal account identifiers. For more information, go to Adding regex-based types or Adding model-based types.

Last updated

Was this helpful?