Image Recognition
Use multimodal models to recognize image content and return text descriptions/answers.
This interface is compatible with Chat Completions, using the same endpoint:
POST /v1/chat/completions.
Try It
POST
/v1/chat/completionshttps://api-platform.ope.aiAuthentication
Uses Bearer Token authentication.
- Header:
Authorization: Bearer <token> - Example:
Authorization: Bearer sk-xxxxxx
Request body (application/json)
| Field | Type | Required | Description | Default / Range |
|---|---|---|---|---|
model | string | Yes | Model ID (multimodal/vision model) | Example: Image-Recognition |
messages | array<object> | Yes | Conversation message list (supports mixed image-text content) | - |
max_tokens | integer | No | Maximum output tokens | - |
temperature | number | No | Sampling temperature | Default 1; Range 0~2 |
top_p | number | No | Nucleus sampling parameter | Default 1; Range 0~1 |
top_k | integer | No | Top-K sampling parameter | - |
frequency_penalty | number | No | Frequency penalty | Default 0; Range -2~2 |
messages.content (mixed image-text)
messages[].content supports array format, with two common item types:
- Image:
{"type":"image_url","image_url":{"url":"data:image/jpeg;base64,<BASE64_IMAGE>"}}
- Text:
{"type":"text","text":"What is this?"}
image_url.urlcan be either a network image URL or a Data URL (e.g.,data:image/jpeg;base64,...).
Request examples
The domain below is an example:
https://api-platform.ope.ai.
- cURL
- JavaScript
- Go
- Python
- Java
- C#
curl -X POST "https://api-platform.ope.ai/v1/chat/completions" \
-H "Authorization: Bearer $OPEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "Image-Recognition",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABA...(omitted)"
}
},
{ "type": "text", "text": "What is this?" }
]
}
]
}'
const url = "https://api-platform.ope.ai/v1/chat/completions";
const apiKey = process.env.OPEAI_API_KEY;
const res = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "Image-Recognition",
max_tokens: 1024,
messages: [
{
role: "user",
content: [
{
type: "image_url",
image_url: { url: "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABA...(omitted)" },
},
{ type: "text", text: "What is this?" },
],
},
],
}),
});
console.log(res.status);
console.log(await res.text());
package main
import (
"bytes"
"io"
"net/http"
"os"
)
func main() {
url := "https://api-platform.ope.ai/v1/chat/completions"
body := []byte(`{
"model": "Image-Recognition",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": { "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABA...(omitted)" }
},
{ "type": "text", "text": "What is this?" }
]
}
]
}`)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OPEAI_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
println(string(b))
}
import os
import requests
resp = requests.post(
"https://api-platform.ope.ai/v1/chat/completions",
headers={
"Authorization": f"Bearer {os.environ.get('OPEAI_API_KEY')}",
"Content-Type": "application/json",
},
json={
"model": "Image-Recognition",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABA...(omitted)"}},
{"type": "text", "text": "What is this?"},
],
}
],
},
timeout=60,
)
print(resp.status_code)
print(resp.text)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String apiKey = System.getenv("OPEAI_API_KEY");
String url = "https://api-platform.ope.ai/v1/chat/completions";
String json = """
{
"model": "Image-Recognition",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": { "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABA...(omitted)" }
},
{ "type": "text", "text": "What is this?" }
]
}
]
}
""";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Authorization", "Bearer " + apiKey)
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(json))
.build();
HttpClient client = HttpClient.newHttpClient();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
public class Program
{
public static async Task Main()
{
var apiKey = Environment.GetEnvironmentVariable("OPEAI_API_KEY");
var url = "https://api-platform.ope.ai/v1/chat/completions";
var json = """
{
"model": "Image-Recognition",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{ "type": "image_url", "image_url": { "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABA...(omitted)" } },
{ "type": "text", "text": "What is this?" }
]
}
]
}
""";
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var resp = await http.PostAsync(url, content);
Console.WriteLine((int)resp.StatusCode);
Console.WriteLine(await resp.Content.ReadAsStringAsync());
}
}
Response examples
- 200
- 400
- 429
{
"id": "string",
"object": "chat.completion",
"created": 0,
"model": "string",
"choices": [
{
"index": 0,
"message": {
"role": "system",
"content": "string",
"name": "string",
"tool_calls": [
{
"id": "string",
"type": "function",
"function": { "name": "string", "arguments": "string" }
}
],
"tool_call_id": "string",
"reasoning_content": "string"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0,
"prompt_tokens_details": {
"cached_tokens": 0,
"text_tokens": 0,
"audio_tokens": 0,
"image_tokens": 0
},
"completion_tokens_details": {
"text_tokens": 0,
"audio_tokens": 0,
"reasoning_tokens": 0
}
},
"system_fingerprint": "string"
}
{
"error": { "message": "string", "type": "string", "param": "string", "code": "string" }
}
{
"error": { "message": "string", "type": "string", "param": "string", "code": "string" }
}