Skip to main content

Quick Start Snippets

Copy. Paste. Run. Working code for every engine in under 30 seconds.

30 seconds to first AI call
NPC Dialogue Generator

Generate context-aware NPC dialogue. Just set your API key and run.

pip install requests ~$0.003 per call
import requests

API_KEY = "mg_live_YOUR_KEY_HERE"  # Get yours at monstergaming.ai/onboard

response = requests.post(
    "https://gateway.monstergaming.ai/v1/chat/completions",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "model": "deepseek-chat",
        "messages": [
            {"role": "system", "content": "You are a grumpy blacksmith NPC in a medieval RPG. "
             "The player has visited 3 times. You're warming up to them but won't admit it."},
            {"role": "user", "content": "Got any new swords today?"}
        ],
        "max_tokens": 150,
        "temperature": 0.8
    }
)

npc_line = response.json()["choices"][0]["message"]["content"]
print(f"Blacksmith: {npc_line}")
AI Code Review

Scan your game code for bugs. Paste any file and get actionable feedback.

Single file ~$0.005 per scan
import requests

API_KEY = "mg_live_YOUR_KEY_HERE"

code_to_review = """
void Update() {
    if (Input.GetKeyDown(KeyCode.Space))
        rb.AddForce(Vector3.up * jumpForce);
        isGrounded = false;  // BUG: always runs (missing braces)
}
"""

response = requests.post(
    "https://gateway.monstergaming.ai/v1/chat/completions",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "model": "deepseek-chat",
        "messages": [
            {"role": "system", "content": "You are a game dev QA expert. "
             "Find bugs, rate severity (CRITICAL/HIGH/MEDIUM/LOW), suggest fixes. "
             "Be concise. Use code blocks for fixes."},
            {"role": "user", "content": f"Review this code:\n```\n{code_to_review}\n```"}
        ],
        "max_tokens": 500
    }
)

print(response.json()["choices"][0]["message"]["content"])
Batch Localization

Translate game strings to multiple languages in one call.

Batch-ready ~$0.002 per string
import requests, json

API_KEY = "mg_live_YOUR_KEY_HERE"

strings_to_translate = [
    "Fire at will!",
    "Health potion restored 50 HP",
    "Quest complete: The Dragon's Lair"
]

response = requests.post(
    "https://gateway.monstergaming.ai/v1/chat/completions",
    headers={"Authorization": f"Bearer {API_KEY}"},
    json={
        "model": "deepseek-chat",
        "messages": [
            {"role": "system", "content": "Translate these game strings to Korean, Japanese, "
             "and Spanish. Output as JSON: {\"ko\": [...], \"ja\": [...], \"es\": [...]}. "
             "Preserve game context (Fire = shoot, not element)."},
            {"role": "user", "content": json.dumps(strings_to_translate)}
        ],
        "max_tokens": 500,
        "temperature": 0.3
    }
)

translations = response.json()["choices"][0]["message"]["content"]
print(translations)
NPC Dialogue (Node.js)

Works with any Node.js project. Zero dependencies beyond fetch.

Node 18+ ~$0.003 per call
const API_KEY = "mg_live_YOUR_KEY_HERE";

const response = await fetch("https://gateway.monstergaming.ai/v1/chat/completions", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    model: "deepseek-chat",
    messages: [
      { role: "system", content: "You are a mysterious fortune teller NPC. Speak in riddles. Short responses." },
      { role: "user", content: "What lies ahead on my journey?" }
    ],
    max_tokens: 100,
    temperature: 0.9
  })
});

const data = await response.json();
console.log("Fortune Teller:", data.choices[0].message.content);
console.log("Cost:", `$${(data.usage.total_tokens * 0.000002).toFixed(6)}`);
Streaming Response (Browser)

Real-time streaming for chat UIs. Works in any browser.

Browser-ready ~$0.003 per call
async function streamNPC(playerInput) {
  const response = await fetch("https://gateway.monstergaming.ai/v1/chat/completions", {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${API_KEY}`,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "deepseek-chat",
      messages: [
        { role: "system", content: "You are a tavern keeper. Friendly but busy." },
        { role: "user", content: playerInput }
      ],
      max_tokens: 150,
      stream: true
    })
  });

  const reader = response.body.getReader();
  const decoder = new TextDecoder();
  let fullText = "";

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    const chunk = decoder.decode(value);
    for (const line of chunk.split("\n")) {
      if (line.startsWith("data: ") && line !== "data: [DONE]") {
        const json = JSON.parse(line.slice(6));
        const token = json.choices[0]?.delta?.content || "";
        fullText += token;
        document.getElementById("npc-text").textContent = fullText;
      }
    }
  }
}
NPC Dialogue Component

Drop this on any NPC GameObject. Generates contextual dialogue on interaction.

Unity 2021+ Newtonsoft.Json ~$0.003 per line
using UnityEngine;
using UnityEngine.Networking;
using System.Collections;
using Newtonsoft.Json.Linq;

public class MonsterNPC : MonoBehaviour
{
    [SerializeField] private string apiKey = "mg_live_YOUR_KEY_HERE";
    [SerializeField] private string personality = "A grumpy blacksmith who secretly cares";
    [TextArea] public string lastResponse;

    public void GenerateDialogue(string playerSays)
    {
        StartCoroutine(CallMonsterAI(playerSays));
    }

    private IEnumerator CallMonsterAI(string input)
    {
        var body = JsonUtility.ToJson(new {
            model = "deepseek-chat",
            messages = new[] {
                new { role = "system", content = personality + ". One sentence max." },
                new { role = "user", content = input }
            },
            max_tokens = 80
        });

        var request = new UnityWebRequest(
            "https://gateway.monstergaming.ai/v1/chat/completions",
            "POST"
        );
        request.uploadHandler = new UploadHandlerRaw(System.Text.Encoding.UTF8.GetBytes(body));
        request.downloadHandler = new DownloadHandlerBuffer();
        request.SetRequestHeader("Authorization", $"Bearer {apiKey}");
        request.SetRequestHeader("Content-Type", "application/json");

        yield return request.SendWebRequest();

        if (request.result == UnityWebRequest.Result.Success)
        {
            var json = JObject.Parse(request.downloadHandler.text);
            lastResponse = json["choices"][0]["message"]["content"].ToString();
        }
    }
}
NPC Dialogue Node

Attach to any NPC node. Call generate_dialogue() on interaction.

Godot 4.x GDScript ~$0.003 per line
extends Node

@export var api_key: String = "mg_live_YOUR_KEY_HERE"
@export var personality: String = "A mysterious merchant who trades in secrets"

signal dialogue_received(text: String)

func generate_dialogue(player_input: String) -> void:
    var http = HTTPRequest.new()
    add_child(http)
    http.request_completed.connect(_on_response.bind(http))

    var body = JSON.stringify({
        "model": "deepseek-chat",
        "messages": [
            {"role": "system", "content": personality + ". Keep responses under 2 sentences."},
            {"role": "user", "content": player_input}
        ],
        "max_tokens": 100
    })

    var headers = [
        "Authorization: Bearer " + api_key,
        "Content-Type: application/json"
    ]

    http.request(
        "https://gateway.monstergaming.ai/v1/chat/completions",
        headers, HTTPClient.METHOD_POST, body
    )

func _on_response(result, code, headers, body, http):
    http.queue_free()
    if code == 200:
        var json = JSON.parse_string(body.get_string_from_utf8())
        var text = json["choices"][0]["message"]["content"]
        dialogue_received.emit(text)
Quick Test (Terminal)

Verify your API key works. Paste into any terminal.

Any OS ~$0.001
curl -X POST https://gateway.monstergaming.ai/v1/chat/completions \
  -H "Authorization: Bearer mg_live_YOUR_KEY_HERE" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-chat",
    "messages": [
      {"role": "system", "content": "You are a game NPC. One sentence."},
      {"role": "user", "content": "Hello!"}
    ],
    "max_tokens": 50
  }'
List Available Models

See all 385+ models available through your account.

No cost
curl https://gateway.monstergaming.ai/v1/models \
  -H "Authorization: Bearer mg_live_YOUR_KEY_HERE"

Get Your API Key in 30 Seconds

Sign up, get $5 free credit, paste your key into any snippet above. That's it.

Get Started Free