Capabilities
Generating Text
We provide a general-purpose text generation API that can be used to generate a wide variety of content for your game.
Examples of content generation tasks our API is great for
-
Creating NPC personalities and backstories
Make your NPCs feel more realistic by generating unique personalities and backstories for them.
-
Enabling dynamic dialogue
Generate realistic dialogue for your game on the fly, allowing for dynamic conversations between players and NPCs.
-
World/level generation
Create new levels based on the actions and decisions of your player in prior levels to create a truly responsive game world.
-
Generating world news and events
Provide your players with a living, breathing world by generating news and events grounded in reality.
-
Generating item descriptions
Give life to the items in your game by generating unique and interesting descriptions for them.
-
Anything else
The sky is the limit with generative AI and these are just a few of our more popular examples. What will you create?
Constructing your prompt
The prompt is the input you provide to the AI. Prompts come in two required parts:
-
System message: This is a message from the game world to the AI. It's a description of what the AI will be tasked with generating and may include the current state of the game world or relevant context.
Tip: You can think of the system message as instructions to the AI, telling them what they will generate.
-
User message: This is a message from the player to the AI. It's a question, a request, or a statement that the AI will use to generate content from.
Tip: You can think of the user message as the input to the AI that will be responded to within the rules set up in the system message.
Now that you understand how prompts are built, you're ready to start generating text!
The better your prompt, the better the output — so here are some tips for constructing a great prompt to generate the highest-quality content for your game:
- Be specific: The more specific your prompt, the better the output. For example, instead of "generate a story", try "generate a story about a detective in a small town who is trying to solve the murder of a local baker".
- Provide an example: A great way to ensure you'll get output you expect is to provide an example of both input and output in the system message; the AI will match the tone and style of your example.
Make your API request
curl https://api.chromagolem.com/v1/chat/completions \ -H "Content-Type: application/json" \ -d '{ "api_key": "cg-ABCDEFGHIJKLMNOPQRSTUVWXYZ", "client_id": "123456789", "messages": [ { "role": "system", "content": "You are a blacksmith specializing in katanas and nodachis in a small medieval fantasy town. [...]" }, { "role": "user", "content": "What do you have for sale?" } ] }'
Code example
This example will make a request to our APIs directly from your console. You can use this as a starting point to integrate our APIs into your game using whatever web request library you're familiar with.
Required parameters
api_key client_id messagesOptional parameters
generation_onlyusing System.Net.Http; using Newtonsoft.Json; var url = 'https://api.chromagolem.com/v1/chat/completions'; var data = new { api_key = "cg-ABCDEFGHIJKLMNOPQRSTUVWXYZ", client_id = "123456789", messages = new[] { new { role = "system", content = "You are a blacksmith specializing in katanas and nodachis in a small medieval fantasy town. [...]" }, new { role = "user", content = "What do you have for sale?" } } }; var json = JsonConvert.SerializeObject(data); var content = new StringContent(json, Encoding.UTF8, "application/json"); using(var client = new HttpClient()) { var response = await client.PostAsync(url, content); var responseString = await response.Content.ReadAsStringAsync(); Console.WriteLine(responseString); }
Code example
This example will make a request to our APIs directly from your console. You can use this as a starting point to integrate our APIs into your game using whatever web request library you're familiar with.
Required parameters
api_key client_id messagesOptional parameters
generation_onlyimport requests url = 'https://api.chromagolem.com/v1/chat/completions' data = { "api_key": "cg-ABCDEFGHIJKLMNOPQRSTUVWXYZ", "client_id": "123456789", "messages": [ { "role": "system", "content": "You are a blacksmith specializing in katanas and nodachis in a small medieval fantasy town. [...]" }, { "role": "user", "content": "What do you have for sale?" } ] } headers = { "Content-Type": "application/json" } response = requests.post(url, json=data, headers=headers) print(response.json())
Code example
This example will make a request to our APIs directly from your console. You can use this as a starting point to integrate our APIs into your game using whatever web request library you're familiar with.
Required parameters
api_key client_id messagesOptional parameters
generation_onlyrequire 'net/http' require 'json' uri = URI('https://api.chromagolem.com/v1/chat/completions') request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json') request.body = JSON.dump({ api_key: "cg-ABCDEFGHIJKLMNOPQRSTUVWXYZ", client_id: "123456789", messages: [ { role: "system", content: "You are a blacksmith specializing in katanas and nodachis in a small medieval fantasy town. [...]" }, { role: "user", content: "What do you have for sale?" } ] }) response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http| http.request(request) end puts response.body
Code example
This example will make a request to our APIs directly from your console. You can use this as a starting point to integrate our APIs into your game using whatever web request library you're familiar with.
Required parameters
api_key client_id messagesOptional parameters
generation_only#include <iostream> #include <string> #include <curl/curl.h> int main() { CURL *curl; CURLcode res; std::string readBuffer; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "https://api.chromagolem.com/v1/chat/completions"); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"api_key\": \"cg-ABCDEFGHIJKLMNOPQRSTUVWXYZ\", \"client_id\": \"123456789\", \"messages\": [{\"role\": \"system\", \"content\": \"You are a blacksmith specializing in katanas and nodachis in a small medieval fantasy town. [...]\"}, {\"role\": \"user\", \"content\": \"What do you have for sale?\"}]}"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, "Content-Type: application/json"); res = curl_easy_perform(curl); if(res != CURLE_OK) fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); curl_easy_cleanup(curl); } return 0; }
Code example
This example will make a request to our APIs directly from your console. You can use this as a starting point to integrate our APIs into your game using whatever web request library you're familiar with.
Required parameters
api_key client_id messagesOptional parameters
generation_onlyRequest parameters
Parameter | Description |
---|---|
Required
|
Your API key that identifies you, the developer. You can create and find your API keys on your dashboard. |
Required
|
A unique client ID that refers to a specific player. This should typically be a value that is randomized for each player that does not identify them in any way, but does differentiate them from other players. |
Required
|
The messages array is a list of messages that the AI will use to generate content. Each message object should have a role and content property. The role property should be either "system", "user", or "assistant" and the content property should be a string. |
Optional
|
Defaults false. Setting this to true will omit all structure and metadata for your response, and only return the generated text as plaintext. |
Response format See full documentation
{ "choices": [ { "message": { "content": "Ah, welcome to my humble forge! I take great pride in crafting some of the finest blades in the realm, each a blend of art and functionality. Take a look around and let me know if anything catches your eye!", "role": "assistant" }, "finish_reason": "stop", "content_filter_results": { "hate": { "filtered": false, "severity": "safe" }, "self_harm": { "filtered": false, "severity": "safe" }, "sexual": { "filtered": false, "severity": "safe" }, "violence": { "filtered": false, "severity": "safe" } } } ], "created": 1723233503, "id": "chatcmpl-9uFxrHYZYk2CxnfQIU854bvmOpuRU", "model": "gpt-35-turbo", "usage": { "completion_tokens": 45, "prompt_tokens": 42, "total_tokens": 87 } }
Extra output with your generation
The text you generate is always available in the request output, but we also act as a drop-in replacement for OpenAI's API. This means you'll get the same metadata about the request that you would get from OpenAI, including the number of tokens used, a unique identifier for the generation, and the model used.
Feel free to ignore this extra data if you don't need it, but it can be useful for debugging, tracking usage, or filtering content for various reasons in your game client. You are only charged for tokens used in your generated text, not for the metadata.
Just give me the text!
If you prefer to just receive your generated text back without any extra metadata, you can set the optional
generation_only
parameter to true
in your request. This will remove all the extra data and return only the text generated.
Ah, welcome to my humble forge! I take great pride in crafting some of the finest blades in the realm, each a blend of art and functionality. Take a look around and let me know if anything catches your eye!
Extra output with your generation
The text you generate is always available in the request output, but we also act as a drop-in replacement for OpenAI's API. This means you'll get the same metadata about the request that you would get from OpenAI, including the number of tokens used, a unique identifier for the generation, and the model used.
Feel free to ignore this extra data if you don't need it, but it can be useful for debugging, tracking usage, or filtering content for various reasons in your game client. You are only charged for tokens used in your generated text, not for the metadata.
Just give me the text!
If you prefer to just receive your generated text back without any extra metadata, you can set the optional
generation_only
parameter to true
in your request. This will remove all the extra data and return only the text generated.
Have questions?
Need a little extra help? Join our Discord server for game devs to chat with our team and other developers.