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:
Redact prompts before you send them to a Fireworks model.
Restore the original values in the response.
Control how Textual handles each entity type.
Use synthesized values to de-identify conversations.
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:
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:
You use a Fireworks model to draft replies to customer support messages.
Textual redacts each message before it reaches the model.
Textual then restores the customer's details in the reply.
You de-identify past support conversations.
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.
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
Install the dependencies.
Set the Textual environment variables.
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:
Use Textual to redact each customer message.
Send the redacted message to Fireworks.
To restore the original values, call
unredacton 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:
RedactionSynthesisGroupingSynthesisReplacementSynthesisOff
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.
De-identify each conversation, then write it to a JSONL file. Each line must contain a
messagesarray in the chat format. The code sends all the messages of a conversation to Textual in oneredact_bulkcall. 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.
Upload the dataset, then start a supervised fine-tuning job with firectl, the Fireworks CLI.
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 Textual LangChain integration to redact text inside a chain.
The langchain-fireworks package for the chat model.
The following chain:
Redacts a support ticket.
Summarizes it with a Fireworks model.
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.
To learn more, go to Configuring connections to LLM providers and Configuring the default LLM provider and model.
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_jsonandredact_htmlto 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?