Integrate Unity NLP Architect directly into your development workflow with our REST API.
All API requests must include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Keep your API key secure. Do not expose it in client-side code or public repositories.
Generate Unity code from natural language description
POST https://api.unitynlparchitect.com/v1/generate
Headers:
Content-Type: application/json
Authorization: Bearer YOUR_API_KEY
Body:
{
"description": "Create a 2D platformer character with jump and movement controls",
"language": "csharp",
"format": "unity"
}
200 OK
{
"code": "using UnityEngine;...",
"suggestions": ["Consider adding double jump", "Add camera follow for better gameplay"],
"warnings": []
}
List available code templates
GET https://api.unitynlparchitect.com/v1/templates
Headers:
Authorization: Bearer YOUR_API_KEY
200 OK
{
"templates": [
{
"id": "platformer-2d",
"name": "2D Platformer",
"description": "Basic 2D platformer template with movement and jumping"
},
{ ... }
]
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| description | string | Required | Natural language description of the game component |
| language | string | Required | Output language (e.g. "csharp") |
| format | string | Optional | Output format (e.g. "unity", "pure") |
| template | string | Optional | Template ID to use as base |
Here's how you might call the API from a C# script in Unity:
IEnumerator GenerateCode(string description) {
UnityWebRequest request = new UnityWebRequest("https://api.unitynlparchitect.com/v1/generate", "POST");
byte[] bodyRaw = Encoding.UTF8.GetBytes(JsonUtility.ToJson(new {
description = description,
language = "csharp",
format = "unity"
}));
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("Authorization", "Bearer YOUR_API_KEY");
yield return request.SendWebRequest();
if (request.result != UnityWebRequest.Result.Success) {
Debug.LogError(request.error);
} else {
var response = JsonUtility.FromJson<GenerationResponse>(request.downloadHandler.text);
// Use response.code in your project
}
}