1curl https://api.arliai.com/v1/chat/completions \
2-H "Content-Type: application/json" \
3-H "Authorization: Bearer YOUR_ARLIAI_API_KEY" \
4-d '{
5"model": "TEXT_GENERATION_MODEL",
6"messages": [
7 {"role": "system", "content": "You are a helpful assistant."},
8 {"role": "user", "content": "Hello!"},
9 {"role": "assistant", "content": "Hi!, how can I help you today?"},
10 {"role": "user", "content": "Say hello!"}
11],
12"repetition_penalty": 1.1,
13"temperature": 0.7,
14"top_p": 0.9,
15"top_k": 40,
16"max_completion_tokens": 1024,
17"stream": false
18}'请登录以使用您的 API 密钥测试此示例。
注意:某些模型可能不接受系统提示词。请将 YOUR_ARLIAI_API_KEY 替换为您的实际密钥。
1curl https://api.arliai.com/v1/completions \
2-H "Content-Type: application/json" \
3-H "Authorization: Bearer YOUR_ARLIAI_API_KEY" \
4-d '{
5"model": "TEXT_GENERATION_MODEL",
6"prompt": "<|begin_of_text|><|start_header_id|>system<|end_header_id|>\n\nYou are an assistant AI.<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nHello there!<|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n",
7"repetition_penalty": 1.1,
8"temperature": 0.7,
9"top_p": 0.9,
10"top_k": 40,
11"max_completion_tokens": 1024,
12"stream": false
13}'请登录以使用您的 API 密钥测试此示例。
注意:使用补全时,请确保为每个模型使用建议的提示词格式。所示示例为 Llama 3 Instruct 格式。请将 YOUR_ARLIAI_API_KEY 替换为您的实际密钥。
1curl https://api.arliai.com/v1/embeddings \
2-H "Content-Type: application/json" \
3-H "Authorization: Bearer YOUR_ARLIAI_API_KEY" \
4-d '{
5 "model": "EMBEDDING_MODEL_NAME",
6 "input": [
7 "The food was delicious.",
8 "The service was slow."
9 ],
10 "encoding_format": "float"
11}'请登录以使用您的 API 密钥测试此示例。
注意:请只发送 input 或 messages 中的一个。每次请求最多允许 20 个输入或对话。对于多模态嵌入,请使用带有 base64 图像数据 URI 的 messages。响应包含 usage.prompt_tokens。使用 GET /v1/embedding-models 列出可用模型。请将占位符替换为实际值。
1curl https://api.arliai.com/sdapi/v1/txt2img \
2-H "Content-Type: application/json" \
3-H "Authorization: Bearer YOUR_ARLIAI_API_KEY" \
4-d '{
5 "prompt": "A photo of an astronaut riding a horse on the moon",
6 "negative_prompt": "ugly, blurry, low quality",
7 "steps": 30,
8 "sampler_name": "Default",
9 "width": 1024,
10 "height": 1024,
11 "sd_model_checkpoint": "IMAGE_GENERATION_MODEL",
12 "seed": -1,
13 "cfg_scale": 7
14}'请登录以使用您的 API 密钥测试此示例。
注意:请以 JSON 形式在请求正文中发送参数。sd_model_checkpoint 和 prompt 字段为必填项。生成的图像将以 base64 编码字符串的形式返回到 images 数组中。最大 steps 为 40。请根据需要替换 YOUR_ARLIAI_API_KEY 和模型名称。
1# First, get your base64 encoded image string, e.g., using:
2# base64 input_image.png | tr -d '\n' > image.b64
3# Then copy the content of image.b64 into the init_images array below
4
5curl https://api.arliai.com/sdapi/v1/img2img \
6-H "Content-Type: application/json" \
7-H "Authorization: Bearer YOUR_ARLIAI_API_KEY" \
8-d '{
9 "init_images": ["YOUR_BASE64_ENCODED_IMAGE_STRING_HERE"],
10 "prompt": "Make the horse blue",
11 "negative_prompt": "ugly, blurry, low quality, text, watermark",
12 "steps": 30,
13 "sampler_name": "Default",
14 "width": 1024,
15 "height": 1024,
16 "sd_model_checkpoint": "IMAGE_GENERATION_MODEL",
17 "seed": -1,
18 "cfg_scale": 7,
19 "denoising_strength": 0.75
20}'注意:sd_model_checkpoint、prompt 和 init_images 字段为必填项。init_images 必须是一个数组,其中至少包含一个初始图像的 base64 编码字符串。最大 steps 为 40。请将占位符替换为实际数据。
1# First, get your base64 encoded image string, e.g., using:
2# base64 input_image.png | tr -d '\n' > image.b64
3# Then copy the content of image.b64 into the image field below
4
5curl https://api.arliai.com/sdapi/v1/extra-single-image \
6-H "Content-Type: application/json" \
7-H "Authorization: Bearer YOUR_ARLIAI_API_KEY" \
8-d '{
9 "image": "YOUR_BASE64_ENCODED_IMAGE_STRING_HERE",
10 "upscaler_1": "R-ESRGAN 4x+",
11 "upscaling_resize": 2
12}'注意:image 字段为必填项,且必须包含要放大图像的 base64 编码字符串。放大后的图像将以 base64 编码字符串的形式返回到 image 字段中(不是数组)。请将占位符替换为实际数据。