Generate text, images, and code with AI. Use modern LLMs in your own apps.
Try in Applaa Builder — FreeAI models don't read words — they read tokens. A token is roughly 4 characters or ¾ of a word. 'Hello world' is about 2 tokens. Why does it matter? Because AI models have a context window — a maximum number of tokens they can process at once. Understanding tokens helps you write better prompts!
The way you phrase a prompt dramatically changes the AI's response. Be specific, give context, tell the AI its role, and give examples of what you want. Bad prompt = vague answer. Great prompt = exactly what you need. Let's learn the patterns!
AI models are accessed over the internet using APIs. You send a POST request with your prompt as JSON, the server runs the AI model, and sends back the response. Let's see the structure — even if you don't have an API key, you'll understand exactly how it works!
By default, AI has no memory between calls. To have a conversation, you send the ENTIRE history each time: the system prompt + all previous messages. This is how ChatGPT works under the hood! You maintain a messages array and append each new exchange.
The system prompt is a special message sent before the user's messages. It defines the AI's persona, constraints, and style. Changing the system prompt changes how the AI responds to the same question. This is how apps like Duolingo's AI tutor or Snapchat's AI work!
Sometimes you need AI to return structured data (not just text) so you can use it in your code. Ask the AI to respond with JSON and parse it with JSON.parse(). Modern AI APIs also support 'response_format: json_object' mode. This is powerful for building apps!
Let's combine everything to build a Study Buddy chatbot! It has a system prompt persona, maintains conversation history, handles the user's messages, and formats the response. In a real app you'd connect to an actual AI API, but we'll simulate the full structure.