Skip to main content
These endpoints provide AI-powered writing assistance using the Groq API with LLaMA 3.1.
All AI writing endpoints require a Groq API key configured in the .env file. See Installation for setup instructions.

Polish Writing

Improve clarity and flow while preserving the original meaning and voice.
POST /api/rewrite
curl -X POST http://127.0.0.1:5000/api/rewrite \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Today was ok. Did some work stuff and felt kind of tired."
  }'

Request Body

text
string
required
The journal entry text to rewrite. Maximum 50,000 characters.

Response

rewritten
string
The improved version of the text
Example Response:
{
  "rewritten": "Today felt manageable, though energy was lower than usual. I spent most of my time focused on work tasks, and by the evening, fatigue had definitely set in. It was one of those steady but draining days."
}

How It Works

The AI:
  • Keeps your first-person voice
  • Preserves original meaning and emotions
  • Maintains similar length
  • Does not add new facts or change the narrative
  • Improves clarity and flow

Generate from Nudges

Transform quick notes or bullet points into a complete journal entry.
POST /api/generate-from-nudges
curl -X POST http://127.0.0.1:5000/api/generate-from-nudges \
  -H "Content-Type: application/json" \
  -d '{
    "nudges": [
      "Morning walk in the park",
      "Productive team meeting",
      "Coffee with Sarah",
      "Finished reading chapter 5"
    ],
    "date": "March 5, 2026"
  }'

Request Body

nudges
array
required
Array of strings containing quick notes or bullet points. Maximum 20 items.
date
string
The date context for the entry (e.g., “March 5, 2026” or “today”). Used for natural phrasing.

Response

entry
string
A complete, well-written journal entry generated from the nudges
Example Response:
{
  "entry": "I started my day with a refreshing walk through the park, which helped clear my mind before diving into work. The team meeting this morning was particularly productive—we made solid progress on the project timeline and everyone seemed aligned.\n\nIn the afternoon, I grabbed coffee with Sarah. It was great catching up and hearing about her recent travels. Later in the evening, I finally finished chapter 5 of my book, which had some fascinating insights into habit formation. Overall, it felt like a well-balanced day with a good mix of productivity and connection."
}

How It Works

The AI:
  • Writes in first person
  • Creates natural flowing prose
  • Connects moments into a cohesive narrative
  • Adds appropriate transitions
  • Includes subtle emotional reflection
  • Generates 2-4 paragraphs
  • Does not invent facts

Get Writing Suggestions

Get personalized suggestions to continue or deepen your journal entry.
POST /api/suggest
curl -X POST http://127.0.0.1:5000/api/suggest \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Today I felt overwhelmed at work. Too many deadlines."
  }'

Request Body

text
string
Your current draft text. If empty, suggestions will be based on recent entries.

Response

suggestions
array
Array of 3 suggestion objects, each with type and text fields
Example Response:
{
  "suggestions": [
    {
      "type": "continue",
      "text": "Which specific deadline is causing the most stress? Writing about it might help break down the problem into manageable steps."
    },
    {
      "type": "reflect",
      "text": "How does your body feel when you think about these deadlines? Are there patterns in when work stress shows up?"
    },
    {
      "type": "gratitude",
      "text": "Even on tough days, what's one small moment you appreciated? Maybe a coworker's help or a quiet break?"
    }
  ]
}

Suggestion Types

  • continue: Helps expand your current thought
  • reflect: Encourages deeper emotional reflection
  • gratitude: Offers a positive reframe
The suggestions consider:
  • Your current draft
  • Recent entry patterns
  • Recent mood trends
  • Appropriately supportive tone

Summarize Text

Get a concise summary of a longer journal entry.
POST /api/summarize
curl -X POST http://127.0.0.1:5000/api/summarize \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Today was incredibly eventful. I started the morning..."
  }'

Request Body

text
string
required
The text to summarize

Response

summary
string
A concise 1-2 sentence summary
Example Response:
{
  "summary": "Had a busy but fulfilling day with a productive morning at work followed by quality time with friends in the evening. Feeling grateful for the balance between professional achievements and personal connections."
}

Error Responses

AI Not Configured

{
  "error": "AI not configured. Add GROQ_API_KEY to .env"
}
HTTP Status: 500

Text Too Long

{
  "error": "Text too long"
}
HTTP Status: 400

No Data Provided

{
  "error": "No data provided"
}
HTTP Status: 400

Rate Limited

If you exceed Groq’s rate limits, you’ll receive an error from the API. The free tier typically allows:
  • 30 requests per minute
  • 14,400 requests per day

Performance

  • Typical response time: less than 1 second
  • Uses LLaMA 3.1 8B Instant model
  • Fast inference optimized for real-time writing assistance

Privacy Considerations

While Reflect AI stores all data locally, these AI endpoints send text to Groq’s API for processing. Only the specific text you request to rewrite, generate, or analyze is sent—never your full journal.
  • Text is sent to Groq API for processing
  • Groq processes text but does not store it long-term
  • No journal metadata is sent (dates, photos, tags remain local)
  • You can disable AI features by removing the GROQ_API_KEY
See Groq API Privacy for detailed information.

Next Steps

AI Insights

Pattern analysis and summaries

Using AI Features

User guide for AI tools

Build docs developers (and LLMs) love