Getting Started with AI

Welcome to AI development with Forge! This guide will walk you through the essential steps to get started with AI-powered applications. Whether you're new to AI or an experienced developer, this guide will help you set up your first AI integration and start building intelligent features.

Prerequisites

Before you begin, make sure you have:

  • A Forge account with access to AI features
  • Basic knowledge of web development (HTML, CSS, JavaScript)
  • Familiarity with API integrations
  • An understanding of your AI use case

Quick Start Guide

Step 1: Choose Your AI Service

Forge supports integration with multiple AI services:

  • OpenAI: GPT models for text generation and conversation
  • Google AI: Machine learning and natural language processing
  • Azure Cognitive Services: Microsoft's AI platform
  • Custom Models: Your own trained AI models

Step 2: Set Up Forge Ignite as Your Backend Proxy

Forge sites are static — they have no server-side runtime. Never store API keys in your Forge site or expose them in client-side code. Instead, use Forge Ignite as a secure backend proxy to handle AI service calls.

  1. Sign up for your chosen AI service provider and generate API keys
  2. Enable Forge Ignite on your Forge project
  3. Store API keys in your Forge Ignite environment variables (server-side, never exposed to the browser)
  4. Create Ignite Cloud Code functions that proxy requests to AI services
  5. Call your Ignite endpoints from your frontend code

Step 3: Configure Forge Ignite Environment Variables

Set up your AI service credentials securely in Forge Ignite:

  1. Navigate to your Forge Ignite dashboard
  2. Go to Settings Environment Variables
  3. Add your API keys using descriptive names like OPENAIAPIKEY or GOOGLEAIKEY
  4. These variables are only accessible server-side in your Ignite Cloud Code — never sent to the browser

Step 4: Create Your First AI Integration

Build your AI integration using the Ignite proxy pattern:

  1. Write a Cloud Code function in Forge Ignite that calls the AI service
  2. Create a frontend function that calls your Ignite endpoint
  3. Implement error handling on both the frontend and backend
  4. Test your integration thoroughly

AI Integration Architecture

The recommended pattern for AI integrations on Forge:

Never Do This — Client-Side API Calls

Calling AI services directly from the browser exposes your API keys to anyone who inspects your page source or network traffic:

// NEVER do this — API key is exposed to the browser
const response = await fetch('https://api.openai.com/v1/chat/completions', {
    method: 'POST',
    headers: {
        'Authorization': 'Bearer sk-your-api-key-here',
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({
        model: 'gpt-4',
        messages: [{ role: 'user', content: prompt }]
    })
});

Do This — Forge Ignite Backend Proxy

Forge Ignite Cloud Code (server-side):

Your API key stays safely on the server. The Cloud Code function acts as a proxy between your frontend and the AI service:

// Forge Ignite Cloud Code — runs server-side, API key is secure
Parse.Cloud.define('generateText', async (request) => {
    const { prompt } = request.params;

    const response = await fetch('https://api.openai.com/v1/chat/completions', {
        method: 'POST',
        headers: {
            'Authorization': Bearer ${process.env.OPENAIAPIKEY},
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            model: 'gpt-4',
            messages: [{ role: 'user', content: prompt }]
        })
    });

    const data = await response.json();
    return data.choices[0].message.content;
});

Frontend code (client-side):

Your frontend calls the Ignite endpoint — no API keys are ever exposed:

// Frontend — calls your Forge Ignite endpoint, no keys exposed
async function generateText(prompt) {
    const result = await Parse.Cloud.run('generateText', { prompt });
    return result;
}

Best Practices

Security First

The most important rule for AI integrations on Forge:

  • Never store API keys in your Forge site — Forge sites are static and any secrets in your code are visible to the browser
  • Always use Forge Ignite as a backend proxy for AI service calls
  • Store all API keys in Forge Ignite environment variables (server-side only)
  • Implement rate limiting and input validation in your Ignite Cloud Code
  • Use different API keys for staging and production environments

AI Integration

Follow these best practices when integrating AI:

  • Start with simple AI features and gradually increase complexity
  • Implement proper error handling in both your Ignite Cloud Code and frontend
  • Use caching in Ignite to reduce redundant API calls and improve response times
  • Monitor AI usage and costs through your service provider's dashboard
  • Ensure AI features are accessible and inclusive

Data Management

Handle data responsibly when working with AI:

  • Follow data privacy regulations and best practices
  • Implement proper data security measures in your Ignite backend
  • Use anonymized data when possible
  • Document your data handling procedures

User Experience

Design AI features with users in mind:

  • Make AI features intuitive and easy to use
  • Provide clear feedback when AI is processing
  • Allow users to opt out of AI features
  • Test AI features with diverse user groups

Testing Your AI Integration

Unit Testing

Test your AI components:

  • Mock AI service responses for testing
  • Test error scenarios and edge cases in your Ignite Cloud Code
  • Validate input/output formats
  • Test performance under load

Integration Testing

Test the complete AI workflow:

  • Test end-to-end flow from frontend to Ignite to AI service
  • Verify Ignite environment variable configuration
  • Test error handling and recovery on both sides
  • Validate user experience

Next Steps

Now that you've set up your first AI integration:

Remember: Always use Forge Ignite as your backend proxy for AI service calls. Never expose API keys in your Forge site's client-side code.

Join the Discussion

Have questions or want to share your experience? Join our community discussion to connect with other developers and get help from the Forge team.

Visit Forum Discussion