# xAI Integration via LowCodeAPI
**Last Updated**: February 10, 2026
## Overview
xAI API for chat completions and AI model interactions
**Categories:**
- {'id': 'image-generation', 'name': 'Image Generation AI'}
## Base Endpoint
https://api.lowcodeapi.com/xai
**Important**: Always include the provider name in the URL path after `api.lowcodeapi.com/`
## Authentication
**Type:** TOKEN
**Official Documentation:** https://docs.x.ai/docs/api-reference
## URL Format (Important)
LowCodeAPI supports two URL formats. **Always try the New Format first**, then fall back to Old Format if needed.
### New Format (Priority)
- Path parameters stay in the URL path
- Do NOT include path parameters as query parameters
- Example: `https://api.lowcodeapi.com/{provider}/resource/{id}?api_token=XXX`
### Old Format (Fallback)
- Path parameters become query parameters
- Example: `https://api.lowcodeapi.com/{provider}/resource/id?id={id}&api_token=XXX`
### Decision Flow for AI Agents
1. Always use **New Format** first - keep path parameters in the URL path
2. If you get a 404 or error, try **Old Format** with sanitized path
3. Log which format worked for future requests to this provider
## API Categories
## Common Endpoints
### Create Chat Completion
**Method:** POST
**LowCodeAPI Path:** /v1/chat/completions
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/chat/completions?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/chat/completions?api_token=YOUR_API_TOKEN
**Request Body:**
| Field | Type | Description |
|-------|------|-------------|
| frequency_penalty | number | |
| logit_bias | object | |
| max_tokens | number | |
| messages | array | |
| model | string | |
| n | number | |
| presence_penalty | number | |
| response_format | object | |
| stop | array | |
| stream | boolean | |
| temperature | number | |
| tool_choice | object | |
| tools | array | |
| top_p | number | |
| user | string | |
**Example Request (New Format):**
```bash
curl -X POST 'https://api.lowcodeapi.com/xai/v1/chat/completions?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/chat-completions
### List Models
**Method:** GET
**LowCodeAPI Path:** /v1/models
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/models?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/models?api_token=YOUR_API_TOKEN
**Example Request (New Format):**
```bash
curl -X GET 'https://api.lowcodeapi.com/xai/v1/models?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/models
### Retrieve Model
**Method:** GET
**LowCodeAPI Path:** /v1/models/{model_id}
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/models/{model_id}?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/models/model_id?model_id={model_id}&api_token=YOUR_API_TOKEN
**Path Parameters:**
| Parameter | Type | Description |
|-----------|------|-------------|
| model_id | string | |
**Example Request (New Format):**
```bash
curl -X GET 'https://api.lowcodeapi.com/xai/v1/models/{model_id}?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/models
### Create a Message
**Method:** POST
**LowCodeAPI Path:** /v1/messages
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/messages?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/messages?api_token=YOUR_API_TOKEN
**Request Body:**
| Field | Type | Description |
|-------|------|-------------|
| max_tokens | number | |
| messages | array | |
| model | string | |
| stop_sequences | array | |
| stream | boolean | |
| system | string | |
| temperature | number | |
| tool_choice | object | |
| tools | array | |
| top_p | number | |
**Example Request (New Format):**
```bash
curl -X POST 'https://api.lowcodeapi.com/xai/v1/messages?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/messages
### Create New Response
**Method:** POST
**LowCodeAPI Path:** /v1/responses
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/responses?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/responses?api_token=YOUR_API_TOKEN
**Request Body:**
| Field | Type | Description |
|-------|------|-------------|
| max_tokens | number | |
| messages | array | |
| model | string | |
| temperature | number | |
**Example Request (New Format):**
```bash
curl -X POST 'https://api.lowcodeapi.com/xai/v1/responses?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/responses
### Retrieve Previous Response
**Method:** GET
**LowCodeAPI Path:** /v1/responses/{response_id}
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/responses/{response_id}?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/responses/response_id?response_id={response_id}&api_token=YOUR_API_TOKEN
**Path Parameters:**
| Parameter | Type | Description |
|-----------|------|-------------|
| response_id | string | |
**Example Request (New Format):**
```bash
curl -X GET 'https://api.lowcodeapi.com/xai/v1/responses/{response_id}?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/responses
### Delete Previous Response
**Method:** DELETE
**LowCodeAPI Path:** /v1/responses/{response_id}
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/responses/{response_id}?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/responses/response_id?response_id={response_id}&api_token=YOUR_API_TOKEN
**Path Parameters:**
| Parameter | Type | Description |
|-----------|------|-------------|
| response_id | string | |
**Example Request (New Format):**
```bash
curl -X DELETE 'https://api.lowcodeapi.com/xai/v1/responses/{response_id}?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/responses
### Create Image Generation
**Method:** POST
**LowCodeAPI Path:** /v1/images/generations
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/images/generations?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/images/generations?api_token=YOUR_API_TOKEN
**Request Body:**
| Field | Type | Description |
|-------|------|-------------|
| model | string | |
| n | number | |
| prompt | string | |
| response_format | string | |
| size | string | |
| user | string | |
**Example Request (New Format):**
```bash
curl -X POST 'https://api.lowcodeapi.com/xai/v1/images/generations?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/images
### Get API Key
**Method:** GET
**LowCodeAPI Path:** /v1/api-key
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/api-key?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/api-key?api_token=YOUR_API_TOKEN
**Example Request (New Format):**
```bash
curl -X GET 'https://api.lowcodeapi.com/xai/v1/api-key?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/api-key
### List Language Models
**Method:** GET
**LowCodeAPI Path:** /v1/language-models
**New Format URL:**
https://api.lowcodeapi.com/xai/v1/language-models?api_token=YOUR_API_TOKEN
**Old Format URL:**
https://api.lowcodeapi.com/xai/v1/language-models?api_token=YOUR_API_TOKEN
**Example Request (New Format):**
```bash
curl -X GET 'https://api.lowcodeapi.com/xai/v1/language-models?api_token=YOUR_API_TOKEN'
```
**Official Documentation:** https://docs.x.ai/docs/api-reference/language-models
## Usage Examples
### Example 1: Basic Chat Completion
Creating a simple text completion or chat message:
```bash
# Create a chat completion - no path parameters needed
curl -X POST "https://api.lowcodeapi.com/xai/v1/chat/completions?api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "your-model-name",
"messages": [
{"role": "user", "content": "Hello, how can you help me?"}
]
}'
# Response includes generated content
```
### Example 2: Text Generation with Path Parameters
Generating text with specific model settings:
```bash
# Generate content using a specific model
curl -X POST "https://api.lowcodeapi.com/xai/v1/models/generate?api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Write a short poem about technology",
"max_tokens": 100
}'
# Or if the provider uses model in the path:
curl -X POST "https://api.lowcodeapi.com/xai/v1/models/{MODEL_ID}:generateContent?api_token=YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Write a short story"}]}]
}'
```
### Example 3: List Available Models
```bash
# Get list of available models
curl -X GET "https://api.lowcodeapi.com/xai/v1/models?api_token=YOUR_API_TOKEN"
```
## Error Handling
LowCodeAPI returns standard HTTP status codes. Common errors:
| Status Code | Description |
|-------------|-------------|
| 200 | Success - Request completed successfully |
| 400 | Bad Request - Invalid parameters or request body |
| 401 | Unauthorized - Invalid or missing API token |
| 403 | Forbidden - Insufficient permissions |
| 404 | Not Found - Endpoint or resource doesn't exist |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Server Error - Provider API error |
All error responses include error details:
```json
{
"data": {
"error": {
"message": "Error description",
"code": "ERROR_CODE"
}
}
}
```
## Complete Endpoint Reference
| Endpoint | Method | Category |
|----------|--------|----------|
| Create Chat Completion | POST | Chat |
| List Models | GET | Models |
| Retrieve Model | GET | Models |
| Create a Message | POST | Message |
| Create New Response | POST | Responses |
| Retrieve Previous Response | GET | Responses |
| Delete Previous Response | DELETE | Responses |
| Create Image Generation | POST | Images |
| Get API Key | GET | API Key |
| List Language Models | GET | Models |
| Get Language Model | GET | Models |
| List Image Generation Models | GET | Models |
| Get Image Generation Model | GET | Models |
| Tokenize Text | POST | Text |
| Get Deferred Chat Completion | GET | Chat |
| Create Completion | POST | Completions |
| Create Completion (Anthropic Compatible) | POST | Completions |
| List Files | GET | Files |
| Get File Metadata | GET | Files |
| Delete File | DELETE | Files |
| Download File | GET | Files |
| Update File | PATCH | Files |
| Initialize File Upload | POST | Files |
| Upload File Chunk | POST | Files |
| Batch Upload Files | POST | Files |
| Complete Batch Upload | POST | Files |
## API Definition Endpoints
You can fetch the complete API specification for this provider:
**New Format (OpenAPI spec):**
```bash
curl 'https://backend.lowcodeapi.com/xai/openapi'
```
**Old Format (API definition):**
```bash
curl 'https://backend.lowcodeapi.com/xai/definition'
```
## Response Format
All responses are wrapped in a `data` key:
```json
{
"data": {
// Actual response from provider (object or array)
}
}
```