AIHub API

Use King’s hosted AI models through OpenAI and Anthropic-compatible APIs. Versioned endpoints are recommended for new integrations; the equivalent unversioned routes are also supported.

Base URL

https://ai.create.kcl.ac.uk/api/v1

Authentication

Send your AIHub API key as a bearer token with every API request.

Authorization: Bearer sk-your-key-here

The Messages endpoint also accepts your AIHub API key in the x-api-key header used by Anthropic clients.

Endpoints

Available AIHub API endpoints
Method Endpoint Description
GET/api/v1/modelsList available models
GET/api/modelsUnversioned alias for the models endpoint
POST/api/v1/chat/completionsCreate a chat completion
POST/api/v1/messagesCreate an Anthropic Messages response (also available at /api/messages)
POST/api/v1/completionsCreate a text completion
POST/api/v1/responsesCreate a Responses API response
POST/api/v1/systemoneStructured decisions with arc:decision (TypeSafe SystemOne)
POST/api/v1/embeddingsCreate embeddings
POST/api/v1/rerankRerank documents against a query
POST/api/v1/images/generationsGenerate PNG images as base64
POST/api/v1/images/editsEdit uploaded images (multipart)
POST/api/v1/audio/speechGenerate speech (binary WAV or MP3)
GET/api/v1/audio/voices?model=MODELList configured voice presets
POST/api/v1/videosSubmit a video job
GET/api/v1/videos/{id}Check your video job
GET/api/v1/videos/{id}/contentDownload a completed MP4
GET/api/v1/agentsList available agents

Image capabilities are advertised by /api/v1/models: supports_image_edit, supports_transparency, max_reference_images and image_sizes. A unified image model uses the same model name for generation and editing. Generation accepts JSON without references, or multipart image[] uploads for image-conditioned creation; editing requires at least one upload. Keep references in the intended picture order. Each image must be a PNG, JPEG or WebP up to 10 MB, with at most the model's configured limit (up to 10).

Use background: "transparent" with a model that supports transparency. AI Hub adds the transparency instruction to your prompt and returns PNG bytes with their alpha channel preserved. Model-specific output sizes are enforced; for Qwen Image 2.1, square output is supported.

Chat completion example

Use agent:code for coding assistance and automatic image understanding through the coding agent. Agent identifiers are supported on Chat Completions; the Responses and Anthropic Messages endpoints currently require base models.

curl https://ai.create.kcl.ac.uk/api/v1/chat/completions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "agent:code",
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'

Anthropic Messages

Use a chat model whose backend supports the Messages API. Requests preserve Anthropic system prompts, content blocks, tools, and thinking options. Set stream: true for native Anthropic SSE events. Model-specific capabilities depend on the configured backend.

from anthropic import Anthropic

client = Anthropic(
    base_url="https://ai.create.kcl.ac.uk/api",
    api_key="sk-your-key-here",
)

message = client.messages.create(
    model="arc:apex",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)

Images, speech, and video

Use the model ID returned by /models. Its mode distinguishes image_generation, image_edit, speech, and video. A generation model cannot be used for image editing.

Image requests accept model, prompt, optional n (1–4), size (model-dependent: 1024x1024, 1344x768, 768x1344, 1216x832, or 832x1216), seed, and num_inference_steps. The configured Qwen models support only 1216x832 (landscape, default) and 832x1216 (portrait); square requests are rejected. Responses use data[].b64_json containing PNG data. Editing accepts one image upload or up to three image[] uploads, each a PNG, JPEG, or WebP up to 10 MB.

Speech accepts model, input (up to 1500 characters), optional voice, and response_format (wav or mp3). The response body is the audio file.

Video accepts model, prompt, optional seconds (4, 6, or 8), size (672x384, 384x672, or 384x384), and seed. H3 supports a multipart input_reference image for animation. Poll the returned job ID until completed, then download its content. Jobs are private to the API key that created them; downloading an unfinished job returns 409.

Creative Hub uses these same configured model backends. Configure active models, their modes, inference endpoints, and default parameters in model administration. Creative options can supply voice metadata and an H3 video_protocol. Only configure fast step counts when the deployed model supports accelerated sampling.

OpenAI SDK

from openai import OpenAI

client = OpenAI(
    base_url="https://ai.create.kcl.ac.uk/api/v1",
    api_key="sk-your-key-here",
)

response = client.chat.completions.create(
    model="agent:code",
    messages=[{"role": "user", "content": "Hello"}],
)

For guides covering API keys, streaming, agents, errors, and billing, view the full AIHub documentation.