Appearance
SDKs & Examples
ArtAPI is fully OpenAI-compatible. Any language or library that supports the OpenAI API works with ArtAPI — just change the base URL.
Python
Install
bash
pip install openaiUsage
python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ARTAPI_KEY"],
base_url="https://app.artapi.ai/v1",
)
response = client.images.generate(
model="flux-dev",
prompt="A futuristic cityscape at dusk, cyberpunk aesthetic",
n=1,
size="1024x1024",
)
image_url = response.data[0].url
print(image_url)Node.js / TypeScript
Install
bash
npm install openaiUsage
typescript
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.ARTAPI_KEY!,
baseURL: 'https://app.artapi.ai/v1',
})
const response = await client.images.generate({
model: 'flux-dev',
prompt: 'A futuristic cityscape at dusk, cyberpunk aesthetic',
n: 1,
size: '1024x1024',
})
console.log(response.data[0].url)curl
bash
curl https://app.artapi.ai/v1/images/generations \
-H "Authorization: Bearer $ARTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "flux-dev",
"prompt": "A futuristic cityscape at dusk, cyberpunk aesthetic",
"n": 1,
"size": "1024x1024"
}'PHP
php
$response = file_get_contents('https://app.artapi.ai/v1/images/generations', false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Authorization: Bearer " . getenv('ARTAPI_KEY') . "\r\nContent-Type: application/json\r\n",
'content' => json_encode([
'model' => 'flux-dev',
'prompt' => 'A futuristic cityscape at dusk',
'n' => 1,
'size' => '1024x1024',
]),
],
]));
$data = json_decode($response, true);
echo $data['data'][0]['url'];Go
go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body, _ := json.Marshal(map[string]any{
"model": "flux-dev",
"prompt": "A futuristic cityscape at dusk",
"n": 1,
"size": "1024x1024",
})
req, _ := http.NewRequest("POST", "https://app.artapi.ai/v1/images/generations", bytes.NewReader(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("ARTAPI_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
var result map[string]any
data, _ := io.ReadAll(resp.Body)
json.Unmarshal(data, &result)
images := result["data"].([]any)
fmt.Println(images[0].(map[string]any)["url"])
}Any language works
As long as you can make an HTTPS POST request with a JSON body and Authorization header, you can use ArtAPI. The examples above are starting points — adapt them to your stack.