### Integrate Reka AI with OpenAI SDK (Python & TypeScript) Source: https://docs.reka.ai/quick-start This section provides examples for integrating Reka Research with the OpenAI SDK in both Python and TypeScript. It shows how to configure the client with Reka's base URL, API key, and model, and then make a chat completion request. ```python from openai import OpenAI client = OpenAI( base_url="https://api.reka.ai/v1", api_key=API_KEY ) completion = client.chat.completions.create( model="reka-flash-research", messages=[ { "role": "user", "content": "Who won the UEFA Nations League 2025?", }, ], ) print(completion.choices[0].message.content) ``` ```typescript import OpenAI from 'openai'; const client = new OpenAI({ baseURL: 'https://api.reka.ai/v1', apiKey: 'API_KEY', }); const completion = client.chat.completions.create({ model: 'reka-flash-research', messages: [ { role: 'user', content: 'Who won the UEFA Nations League 2025?' } ], }); console.log(completion.choices[0].message.content); ``` -------------------------------- ### Chat Completions API Source: https://docs.reka.ai/quick-start This endpoint allows you to interact with Reka Research models using an OpenAI-compatible format. You can send messages and receive responses, including real-time web search and grounded answers. ```APIDOC ## POST /v1/chat/completions ### Description Sends messages to a Reka Research model to get a completion. This endpoint is compatible with OpenAI's chat completions format and supports features like real-time web search and grounded answers. ### Method POST ### Endpoint https://api.reka.ai/v1/chat/completions ### Parameters #### Request Body - **model** (string) - Required - The Reka model to use (e.g., "reka-flash-research"). - **messages** (array) - Required - A list of message objects, where each object has a 'role' (user or assistant) and 'content' (string). ### Request Example ```json { "model": "reka-flash-research", "messages": [ { "role": "user", "content": "Who won the UEFA Nations League 2025?" } ] } ``` ### Response #### Success Response (200) - **choices** (array) - An array of choices, where each choice contains a 'message' object. - **message** (object) - **role** (string) - The role of the message sender (e.g., "assistant"). - **content** (string) - The content of the assistant's reply. #### Response Example ```json { "choices": [ { "message": { "role": "assistant", "content": "The UEFA Nations League 2025 winner has not yet been determined as the tournament has not occurred." } } ] } ``` ``` -------------------------------- ### Guide Assistant Output to JSON with Reka AI Python SDK Source: https://docs.reka.ai/chat This example demonstrates how to prompt the Reka AI assistant to generate a JSON response by providing a partial JSON structure in the assistant's message. It initializes the Reka client, defines a prompt to extract planet information, and uses a json_prefix to guide the output format. The `max_tokens`, `temperature`, and `stop` parameters are used to control the generation. ```python from reka.client import Reka client = Reka(api_key="YOUR_API_KEY") prompt = """ Below is a paragraph from wikipedia: The Solar System is the gravitationally bound system of the Sun and the objects that orbit it. The largest of such objects are the eight planets, in order from the Sun: four terrestrial planets named Mercury, Venus, Earth and Mars, two gas giants named Jupiter and Saturn, and two ice giants named Uranus and Neptune. The terrestrial planets have a definite surface and are mostly made of rock and metal. The gas giants are mostly made of hydrogen and helium, while the ice giants are mostly made of 'volatile' substances such as water, ammonia, and methane. In some texts, these terrestrial and giant planets are called the inner Solar System and outer Solar System planets respectively. Extract information about the planets from this paragraph as a JSON list of objects with keys 'planetName' and 'composition'. The 'composition' key should contain one or two words, and there should be no other keys. """.strip() json_prefix = """.strip() [ { "planetName": """.strip() response = client.chat.create( messages=[ {"role": "user", "content": prompt}, { "role": "assistant", "content": ( "Sure, here is a JSON object conforming to that format:\n\n" f"```json\n{json_prefix}" ), }, ], max_tokens=512, temperature=0.4, stop=["```\n"], model="reka-core-20240501", ) print(json_prefix + response.responses[0].message.content) ``` -------------------------------- ### Make First API Request with Curl Source: https://docs.reka.ai/quick-start This snippet demonstrates how to make an initial API request to Reka Research using curl to retrieve information about the UEFA Nations League 2025 winner. It requires an API key and specifies the model and user query. ```shell curl https://api.reka.ai/v1/chat/completions \ --header 'Authorization: Bearer $API_KEY' \ --header "content-type: application/json" \ --data '{ \ "model": "reka-flash-research", \ "messages": [ \ { \ "role": "user", \ "content": "Who won the UEFA Nations League 2025?" \ } \ ] \ }' ``` -------------------------------- ### Quick Tag Video API Request (PHP) Source: https://docs.reka.ai/vision/api-reference/metadata-tagging/quick-tag-video Shows a PHP implementation for making a POST request to the Reka AI Vision Agent's quicktag endpoint using the Guzzle HTTP client. This example demonstrates setting the API key header and using the 'multipart' option for file uploads. Ensure GuzzleHttp is installed via Composer. ```php request('POST', 'https://vision-agent.api.reka.ai/qa/quicktag', [ 'multipart' => [ [ 'name' => 'video', 'filename' => '', 'contents' => null ] ] 'headers' => [ 'X-Api-Key' => '', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Fetch Reka AI Reels using Go SDK Source: https://docs.reka.ai/vision/api-reference/reel-generation/get-reel-status Provides a Go code example for fetching reels from the Reka AI Vision Agent API. It uses the standard net/http package to make a GET request with the necessary API key and prints the response body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://vision-agent.api.reka.ai/v1/creator/reels/528f7aa1-dec7-4a2b-8e85-a3e7101873ca" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Api-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Videos using Reka AI API (Python, JavaScript, Go, Ruby, Java, PHP, C#, Swift) Source: https://docs.reka.ai/vision/api-reference/video-management/get Demonstrates how to retrieve video data from the Reka AI Vision Agent API. This involves making a POST request to the '/videos/get' endpoint with an API key and specifying video IDs in the request body. The examples cover fetching all videos (empty video_ids array) and specific videos by providing their IDs. Dependencies include HTTP client libraries for each respective language. ```python import requests url = "https://vision-agent.api.reka.ai/videos/get" payload = { "video_ids": [] } # Use specific IDs like ["550e8400-e29b-41d4-a716-446655440000"] to get specific videos headers = { "X-Api-Key": "", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers) print(response.json()) ``` ```javascript const url = 'https://vision-agent.api.reka.ai/videos/get'; const options = { method: 'POST', headers: {'X-Api-Key': '', 'Content-Type': 'application/json'}, body: JSON.stringify({ "video_ids": [] }) // Use specific IDs like ["550e8400-e29b-41d4-a716-446655440000"] to get specific videos }; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://vision-agent.api.reka.ai/videos/get" // Use specific IDs like ["550e8400-e29b-41d4-a716-446655440000"] to get specific videos payload := strings.NewReader("{ \"video_ids\": [] }") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Api-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://vision-agent.api.reka.ai/videos/get") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-Api-Key"] = '' request["Content-Type"] = 'application/json' # Use specific IDs like ["550e8400-e29b-41d4-a716-446655440000"] to get specific videos request.body = "{\n \"video_ids\": [] }" response = http.request(request) puts response.read_body ``` ```java import kong.unirest.HttpResponse; import kong.unirest.Unirest; // ... other imports and class structure ... HttpResponse response = Unirest.post("https://vision-agent.api.reka.ai/videos/get") .header("X-Api-Key", "") .header("Content-Type", "application/json") // Use specific IDs like ["550e8400-e29b-41d4-a716-446655440000"] to get specific videos .body("{\n \"video_ids\": []\n}") .asString(); // Access response body: response.getBody() ``` ```php request('POST', 'https://vision-agent.api.reka.ai/videos/get', [ 'body' => '{ "video_ids": [] }', // Use specific IDs like ["550e8400-e29b-41d4-a716-446655440000"] to get specific videos 'headers' => [ 'Content-Type' => 'application/json', 'X-Api-Key' => '', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; // ... other using statements and class structure ... var client = new RestClient("https://vision-agent.api.reka.ai/videos/get"); var request = new RestRequest(Method.POST); request.AddHeader("X-Api-Key", ""); request.AddHeader("Content-Type", "application/json"); // Use specific IDs like ["550e8400-e29b-41d4-a716-446655440000"] to get specific videos request.AddParameter("application/json", "{\n \"video_ids\": []\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); // Access response content: response.Content ``` ```swift import Foundation let headers = [ "X-Api-Key": " Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) // Process data if needed } }) dataTask.resume() ``` -------------------------------- ### Prompting for Structured JSON Output with Reka AI Python Client Source: https://docs.reka.ai/chat/overview This example shows how to guide the Reka AI assistant to produce a JSON response by providing a partial assistant response as the last message. It uses the `reka.client.Reka` class and demonstrates setting `messages`, `max_tokens`, `temperature`, and `stop` parameters for precise output generation. The output is a JSON list of objects containing planet names and their compositions. ```python from reka.client import Reka client = Reka(api_key="YOUR_API_KEY") prompt = """ Below is a paragraph from wikipedia: The Solar System is the gravitationally bound system of the Sun and the objects that orbit it. The largest of such objects are the eight planets, in order from the Sun: four terrestrial planets named Mercury, Venus, Earth and Mars, two gas giants named Jupiter and Saturn, and two ice giants named Uranus and Neptune. The terrestrial planets have a definite surface and are mostly made of rock and metal. The gas giants are mostly made of hydrogen and helium, while the ice giants are mostly made of 'volatile' substances such as water, ammonia, and methane. In some texts, these terrestrial and giant planets are called the inner Solar System and outer Solar System planets respectively. Extract information about the planets from this paragraph as a JSON list of objects with keys 'planetName' and 'composition'. The 'composition' key should contain one or two words, and there should be no other keys. """.strip() json_prefix = """ [ { "planetName": """.strip() response = client.chat.create( messages=[ {"role": "user", "content": prompt}, { "role": "assistant", "content": ( "Sure, here is a JSON object conforming to that format:\n\n" f"```json\n{json_prefix}" ), }, ], max_tokens=512, temperature=0.4, stop=["```\n"], model="reka-core-20240501", ) print(json_prefix + response.responses[0].message.content) ``` -------------------------------- ### Get Specific Videos using Java Source: https://docs.reka.ai/vision/api-reference/video-management/get This Java example shows how to fetch specific videos from the Reka AI Vision Agent API using the Unirest library. It configures a POST request to the API endpoint, setting the required 'X-Api-Key' and 'Content-Type' headers, and providing a JSON body with video IDs. The response is captured as a String. ```java HttpResponse response = Unirest.post("https://vision-agent.api.reka.ai/videos/get") .header("X-Api-Key", "") .header("Content-Type", "application/json") .body("{\n \"video_ids\": [\n \"550e8400-e29b-41d4-a716-446655440000\"\n ]\n}") .asString(); ``` -------------------------------- ### Upload Video from URL using JavaScript Source: https://docs.reka.ai/vision/api-reference/video-management/upload This JavaScript example utilizes the `fetch` API to upload a video from a URL. It constructs a `FormData` object to include the video file, URL, name, timestamp, index, and thumbnail settings. The API key is included in the request headers. This example assumes a browser environment or a Node.js environment with a `fetch` polyfill. ```javascript const url = 'https://vision-agent.api.reka.ai/videos/upload'; const form = new FormData(); form.append('file', ''); form.append('video_url', 'https://sample-videos.com/zip/10/mp4/SampleVideo_1280x720_1mb.mp4'); form.append('video_name', 'sample_video.mp4'); form.append('video_start_absolute_timestamp', ''); form.append('index', 'true'); form.append('enable_thumbnails', ''); const options = {method: 'POST', headers: {'X-Api-Key': ''}}; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` -------------------------------- ### Upload Video from URL Source: https://docs.reka.ai/vision/api-reference/video-management/upload This section demonstrates how to upload a video by providing its URL. Examples are provided for Python, JavaScript, and Go. ```APIDOC ## POST /websites/reka_ai/videos/upload (from URL) ### Description Uploads a video to the Reka AI platform by specifying its URL. This is an alternative to uploading a local file. ### Method POST ### Endpoint https://vision-agent.api.reka.ai/videos/upload ### Parameters #### Request Body (form-data or multipart/form-data depending on implementation) - **file** (file or string) - Required - This parameter is still required, but can be a placeholder or reference when uploading via URL. - **video_url** (string) - Required - The direct URL to the video file. - **video_name** (string) - Optional - The desired name for the video. - **video_start_absolute_timestamp** (string) - Optional - The absolute timestamp for the start of the video. - **index** (boolean) - Optional - Whether to index the video (e.g., 'true' or 'false'). - **enable_thumbnails** (boolean) - Optional - Whether to enable thumbnail generation. ### Request Example (Python) ```python import requests url = "https://vision-agent.api.reka.ai/videos/upload" # "file" parameter might need a placeholder or actual file content depending on backend implementation files = { "file": "open('', 'rb')" } payload = { "video_url": "https://sample-videos.com/zip/10/mp4/SampleVideo_1280x720_1mb.mp4", "video_name": "sample_video.mp4", "video_start_absolute_timestamp": "", "index": "true", "enable_thumbnails": "" } headers = {"X-Api-Key": ""} response = requests.post(url, data=payload, files=files, headers=headers) print(response.json()) ``` ### Request Example (JavaScript) ```javascript const url = 'https://vision-agent.api.reka.ai/videos/upload'; const form = new FormData(); form.append('file', ''); // Placeholder for file, actual value might depend on backend requirements form.append('video_url', 'https://sample-videos.com/zip/10/mp4/SampleVideo_1280x720_1mb.mp4'); form.append('video_name', 'sample_video.mp4'); form.append('video_start_absolute_timestamp', ''); form.append('index', 'true'); form.append('enable_thumbnails', ''); const options = { method: 'POST', headers: {'X-Api-Key': ''} }; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ### Request Example (Go) ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://vision-agent.api.reka.ai/videos/upload" // The payload structure mimics multipart/form-data payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video_url\"\r\n\r\nhttps://sample-videos.com/zip/10/mp4/SampleVideo_1280x720_1mb.mp4\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video_name\"\r\n\r\nsample_video.mp4\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video_start_absolute_timestamp\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"index\"\r\n\r\ntrue\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"enable_thumbnails\"\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Api-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the video upload was successful. - **video_id** (string) - The unique identifier for the uploaded video. #### Response Example ```json { "message": "Video uploaded successfully via URL", "video_id": "vid_def456uvw" } ``` ``` -------------------------------- ### Fetch Reka AI Reels using PHP SDK Source: https://docs.reka.ai/vision/api-reference/reel-generation/get-reel-status Provides a PHP example using the GuzzleHttp client to fetch reels from the Reka AI Vision Agent API. It configures a GET request with the required API key in the headers and outputs the response body. ```php request('GET', 'https://vision-agent.api.reka.ai/v1/creator/reels/528f7aa1-dec7-4a2b-8e85-a3e7101873ca', [ 'headers' => [ 'X-Api-Key' => '', ], ]); echo $response->getBody(); ?> ``` -------------------------------- ### Quickstart: Reka Chat API Python SDK Usage Source: https://docs.reka.ai/chat/overview This snippet demonstrates the basic usage of the Reka Python SDK to make a single API call. It requires the 'reka-api' package and an API key. The input is a user message, and the output is the model's textual response. ```python from reka.client import Reka # You can also set the API key using the REKA_API_API_KEY environment variable. client = Reka(api_key="YOUR_API_KEY") response = client.chat.create( messages=[ { "content": "What is the fifth prime number?", "role": "user", } ], model="reka-core-20240501", ) print(response.responses[0].message.content) ``` -------------------------------- ### Fetch Reka AI Reels using Swift SDK Source: https://docs.reka.ai/vision/api-reference/reel-generation/get-reel-status Demonstrates fetching reels from the Reka AI Vision Agent API using Swift's Foundation framework. This example uses URLSession to perform a GET request with the API key in the HTTP headers and handles the response. ```swift import Foundation let headers = ["X-Api-Key": ""] let request = NSMutableURLRequest(url: NSURL(string: "https://vision-agent.api.reka.ai/v1/creator/reels/528f7aa1-dec7-4a2b-8e85-a3e7101873ca")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Quick Tag Video API Request (Ruby) Source: https://docs.reka.ai/vision/api-reference/metadata-tagging/quick-tag-video Illustrates how to make a POST request to the Reka AI Vision Agent's quicktag endpoint using Ruby's Net::HTTP library. This example shows how to set headers for API key authentication and construct the multipart/form-data body. Ensure the 'uri' and 'net/http' gems are available. ```ruby require 'uri' require 'net/http' url = URI("https://vision-agent.api.reka.ai/qa/quicktag") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["X-Api-Key"] = '' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video_url\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_fields\"\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` -------------------------------- ### Query Model with Tools and User Input in Python Source: https://docs.reka.ai/chat/function-calling Demonstrates how to query the Reka AI model with defined tools and a user query. It includes setting up the Reka client, preparing messages, and calling the `chat.create` method with `tool_choice='auto'` and the defined tools. The output shows how to extract a tool call from the response. ```python from reka.client import Reka # You can also set the API key using the REKA_API_KEY environment variable. client = Reka(api_key="YOUR_API_KEY") user_query = "Is product a-12345 in stock right now?" messages = [ { "content": user_query, "role": "user", }, ] response = client.chat.create( messages=messages, tool_choice="auto", tools=tools, model="reka-flash", ) tool_call = response.responses[0].message.tool_calls[0] print(tool_call) ``` -------------------------------- ### Streaming Responses via Stream API (Python) Source: https://docs.reka.ai/vision/video-qa Utilize the `/qa/stream` endpoint in Python to get real-time video Q&A responses. This example shows how to make a POST request with video ID and user message, expecting an SSE stream. ```Python import requests import json url = f"{BASE_URL}/qa/stream" # Chat request body payload = { "video_id": "550e8400-e29b-41d4-a716-446655440000", "messages": [ { "role": "user", "content": "What is happening in this video?" } ] } headers = { "X-Api-Key": REKA_API_KEY, "Content-Type": "application/json", } response = requests.post(url, json=payload, headers=headers) print(response.status_code, response.json()) ``` -------------------------------- ### Quick Tag Video API Request (Go) Source: https://docs.reka.ai/vision/api-reference/metadata-tagging/quick-tag-video Provides a Go implementation for sending a POST request to the Reka AI Vision Agent's quicktag endpoint. It demonstrates constructing a multipart/form-data request, including headers for API key authentication. This code requires the standard net/http package. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://vision-agent.api.reka.ai/qa/quicktag" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video_url\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_fields\"\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Api-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Get Specific Videos using C# Source: https://docs.reka.ai/vision/api-reference/video-management/get This C# example demonstrates how to retrieve specific videos using the Reka AI Vision Agent API with the RestSharp library. It configures a POST request, adding the necessary 'X-Api-Key' and 'Content-Type' headers, and appending the JSON request body. The response is then executed and stored. ```csharp var client = new RestClient("https://vision-agent.api.reka.ai/videos/get"); var request = new RestRequest(Method.POST); request.AddHeader("X-Api-Key", ""); request.AddHeader("Content-Type", "application/json"); request.AddParameter("application/json", "{\n \"video_ids\": [\n \"550e8400-e29b-41d4-a716-446655440000\"\n ]\n}", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Search Vision Agent API with Swift Source: https://docs.reka.ai/vision/api-reference/video-search/search-videos This Swift code example demonstrates making a POST request to the Reka AI Vision Agent search API using Foundation's URLSession. It covers setting up the request headers, constructing the JSON body, and handling the response asynchronously. Error handling for network issues is also included. ```swift import Foundation let headers = [ "X-Api-Key": "", "Content-Type": "application/json" ] let parameters = ["query": "person walking on beach"] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://vision-agent.api.reka.ai/search")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ``` -------------------------------- ### Quick Tag Video with Python Source: https://docs.reka.ai/vision/api-reference/metadata-tagging/quick-tag-video_explorer=true This Python snippet demonstrates how to use the requests library to send a video file to the Quick Tag Video endpoint for metadata tagging. It includes setting up the request with files, payload, and headers, and printing the JSON response. ```python import requests url = "https://vision-agent.api.reka.ai/qa/quicktag" files = { "video": "open('', 'rb')" } payload = { "video_url": , "output_fields": } headers = {"X-Api-Key": ""} response = requests.post(url, data=payload, files=files, headers=headers) print(response.json()) ``` -------------------------------- ### List Images with Reka AI Vision Agent API (Go) Source: https://docs.reka.ai/vision/api-reference/image-management/list-images This Go code example demonstrates how to call the Reka AI Vision Agent API to list images. It constructs an HTTP POST request to the /images/list endpoint, setting the 'X-Api-Key' and 'Content-Type' headers. The response body is then read and printed to the console. ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://vision-agent.api.reka.ai/images/list" payload := strings.NewReader("{}") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("X-Api-Key", "") req.Header.Add("Content-Type", "application/json") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### Initialize Reka Client and Send Single Chat Message (Python) Source: https://docs.reka.ai/chat Demonstrates how to initialize the Reka client using an API key and send a single user message to the chat API. It then prints the content of the first response. Ensure the 'reka-api' SDK is installed and an API key is provided. ```python from reka.client import Reka # You can also set the API key using the REKA_API_KEY environment variable. client = Reka(api_key="YOUR_API_KEY") response = client.chat.create( messages=[ { "content": "What is the fifth prime number?", "role": "user", } ], model="reka-core-20240501", ) print(response.responses[0].message.content) ``` -------------------------------- ### Fetch Reka AI Reels using Ruby SDK Source: https://docs.reka.ai/vision/api-reference/reel-generation/get-reel-status Illustrates how to fetch reels from the Reka AI Vision Agent API using Ruby's Net::HTTP library. This example sets up an HTTPS connection, adds the API key to the headers, and prints the response body. ```ruby require 'uri' require 'net/http' url = URI("https://vision-agent.api.reka.ai/v1/creator/reels/528f7aa1-dec7-4a2b-8e85-a3e7101873ca") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Get.new(url) request["X-Api-Key"] = '' response = http.request(request) puts response.read_body ``` -------------------------------- ### Quick Tag Video API Request (C#) Source: https://docs.reka.ai/vision/api-reference/metadata-tagging/quick-tag-video Provides a C# example for sending a POST request to the Reka AI Vision Agent's quicktag endpoint using the RestSharp library. It details how to add the API key header and specify the request body for multipart/form-data. Ensure RestSharp is added as a NuGet package. ```csharp var client = new RestClient("https://vision-agent.api.reka.ai/qa/quicktag"); var request = new RestRequest(Method.POST); request.AddHeader("X-Api-Key", ""); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video_url\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_fields\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Fetch Reels from Reka AI Vision Agent API (Go) Source: https://docs.reka.ai/vision/api-reference/reel-generation/list-reels This Go snippet demonstrates fetching reels from the Reka AI Vision Agent API. It constructs an HTTP GET request, adds the API key to the headers, sends the request using the default client, and prints the response status and body. ```go package main import ( "fmt" "net/http" "io" ) func main() { url := "https://vision-agent.api.reka.ai/v1/creator/reels" req, _ := http.NewRequest("GET", url, nil) req.Header.Add("X-Api-Key", "") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` -------------------------------- ### GET /v1/creator/reels/{id} Source: https://docs.reka.ai/vision/api-reference/reel-generation/get-reel-status Retrieves the status of a specific reel generation job using its unique ID. ```APIDOC ## GET /v1/creator/reels/{id} ### Description Check the status of a reel generation job. ### Method GET ### Endpoint /v1/creator/reels/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The reel generation job ID #### Header Parameters - **X-Api-Key** (string) - Required - API Key for authentication ### Response #### Success Response (200) - **id** (string) - The ID of the reel generation job. - **status** (string) - The current status of the job (queued, processing, completed, failed). - **created_at** (string) - Timestamp when the job was created. - **updated_at** (string) - Timestamp when the job was last updated. - **generation_config** (object) - Configuration used for generation. - **rendering_config** (object) - Configuration used for rendering. - **video_urls** (array) - List of generated video URLs. - **video_ids** (array) - List of generated video IDs. - **prompt** (string) - The prompt used for generation. - **output** (array) - Details of the generated reel output. - **error_message** (string) - An error message if the job failed. #### Response Example ```json { "id": "reel_12345", "status": "completed", "created_at": "2023-10-27T10:00:00Z", "updated_at": "2023-10-27T10:05:00Z", "generation_config": { "template": "moments", "num_generations": 1, "min_duration_seconds": 5, "max_duration_seconds": 10 }, "rendering_config": { "subtitles": true, "aspect_ratio": "16:9" }, "video_urls": [ "https://example.com/video/reel_12345.mp4" ], "video_ids": [ "vid_abcde" ], "prompt": "A scenic mountain landscape", "output": [ { "url": "https://example.com/video/reel_12345.mp4", "duration_seconds": 8.5, "thumbnail_url": "https://example.com/thumbnails/reel_12345.jpg" } ], "error_message": null } ``` #### Error Responses - **401** Unauthorized - **404** Not Found ``` -------------------------------- ### Get Reel Status Endpoint Specification (OpenAPI) Source: https://docs.reka.ai/vision/api-reference/reel-generation/get-reel-status This OpenAPI specification defines the GET endpoint for retrieving the status of a reel generation job. It includes request parameters such as the reel ID and API key, and details the possible response structures for success (200 OK) and error scenarios (401 Unauthorized, 404 Not Found). ```yaml openapi: 3.1.1 info: title: Get reel generation status version: endpoint_reelGeneration.getReelStatus paths: /v1/creator/reels/{id}: get: operationId: get-reel-status summary: Get reel generation status description: Check the status of a reel generation job tags: - "- subpackage_reelGeneration" parameters: - name: id in: path description: The reel generation job ID required: true schema: type: string - name: X-Api-Key in: header required: true schema: type: string responses: '200': description: OK content: application/json: schema: $ref: '#/components/schemas/ReelGenerationResponse' '401': description: Unauthorized content: {} '404': description: Not Found content: {} components: schemas: ReelGenerationResponseStatus: type: string enum: - value: queued - value: processing - value: completed - value: failed GenerationConfigTemplate: type: string enum: - value: moments - value: compilation GenerationConfig: type: object properties: template: $ref: '#/components/schemas/GenerationConfigTemplate' num_generations: type: integer min_duration_seconds: type: integer max_duration_seconds: type: integer RenderingConfig: type: object properties: subtitles: type: boolean aspect_ratio: type: string ReelOutput: type: object properties: url: type: string format: uri duration_seconds: type: number format: double thumbnail_url: type: string format: uri ReelGenerationResponse: type: object properties: id: type: string status: $ref: '#/components/schemas/ReelGenerationResponseStatus' created_at: type: string format: date-time updated_at: type: string format: date-time generation_config: $ref: '#/components/schemas/GenerationConfig' rendering_config: $ref: '#/components/schemas/RenderingConfig' video_urls: type: array items: type: string format: uri video_ids: type: array items: type: string prompt: type: string output: type: array items: $ref: '#/components/schemas/ReelOutput' error_message: type: string required: - id - status - created_at - updated_at ``` -------------------------------- ### List Available Models (C# RestSharp) Source: https://docs.reka.ai/chat/api-reference/get This C# code snippet demonstrates how to get the list of available models using the RestSharp library. It creates a GET request to the models endpoint and adds the API key as a header. ```csharp var client = new RestClient("https://api.reka.ai/v1/models"); var request = new RestRequest(Method.GET); request.AddHeader("X-Api-Key", ""); IRestResponse response = client.Execute(request); ``` -------------------------------- ### Quick Tag Video API Request (Java) Source: https://docs.reka.ai/vision/api-reference/metadata-tagging/quick-tag-video Demonstrates how to send a POST request to the Reka AI Vision Agent's quicktag endpoint using Java with the Unirest library. It includes setting the API key header and constructing the multipart/form-data body. Ensure Unirest is included as a dependency. ```java HttpResponse response = Unirest.post("https://vision-agent.api.reka.ai/qa/quicktag") .header("X-Api-Key", "") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"video_url\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"output_fields\"\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` -------------------------------- ### Fetch Reels from Reka AI Vision Agent API (C#) Source: https://docs.reka.ai/vision/api-reference/reel-generation/list-reels This C# snippet demonstrates fetching reels from the Reka AI Vision Agent API using the RestSharp library. It configures a GET request with the API key in the headers and executes the request to get the response. ```csharp var client = new RestClient("https://vision-agent.api.reka.ai/v1/creator/reels"); var request = new RestRequest(Method.GET); request.AddHeader("X-Api-Key", ""); IRestResponse response = client.Execute(request); ```