import Foundationlet url = URL(string: "https://api.apimart.ai/v1/chat/completions")!let payload: [String: Any] = [ "model": "gpt-5", // サポートされている任意のモデルIDに置き換え可能 "messages": [ [ "role": "system", "content": "You are a professional AI assistant." ], [ "role": "user", "content": "Tell me about the history of artificial intelligence." ] ]]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/chat/completions"; // サポートされている任意のモデルIDに置き換え可能 var payload = @"{ ""model"": ""gpt-5"", ""messages"": [ { ""role"": ""system"", ""content"": ""You are a professional AI assistant."" }, { ""role"": ""user"", ""content"": ""Tell me about the history of artificial intelligence."" } ] }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
#include <stdio.h>#include <curl/curl.h>int main(void) { CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { const char *url = "https://api.apimart.ai/v1/chat/completions"; // "gpt-5" はサポートされている任意のモデルIDに置き換え可能 const char *payload = "{" "\"model\":\"gpt-5\"," "\"messages\":[{\"role\":\"system\",\"content\":\"You are a professional AI assistant.\"},{\"role\":\"user\",\"content\":\"Tell me about the history of artificial intelligence.\"}]" "}"; struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Authorization: Bearer <token>"); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); if(res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); } curl_slist_free_all(headers); curl_easy_cleanup(curl); } curl_global_cleanup(); return 0;}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/chat/completions"(* サポートされている任意のモデルIDに置き換え可能 *)let payload = {|{ "model": "gpt-5", "messages": [ { "role": "system", "content": "You are a professional AI assistant." }, { "role": "user", "content": "Tell me about the history of artificial intelligence." } ]}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/chat/completions"# サポートされている任意のモデルIDに置き換え可能payload <- list( model = "gpt-5", messages = list( list( role = "system", content = "You are a professional AI assistant." ), list( role = "user", content = "Tell me about the history of artificial intelligence." ) ))response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))
import Foundationlet url = URL(string: "https://api.apimart.ai/v1/chat/completions")!let payload: [String: Any] = [ "model": "gpt-5", // サポートされている任意のモデルIDに置き換え可能 "messages": [ [ "role": "system", "content": "You are a professional AI assistant." ], [ "role": "user", "content": "Tell me about the history of artificial intelligence." ] ]]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/chat/completions"; // サポートされている任意のモデルIDに置き換え可能 var payload = @"{ ""model"": ""gpt-5"", ""messages"": [ { ""role"": ""system"", ""content"": ""You are a professional AI assistant."" }, { ""role"": ""user"", ""content"": ""Tell me about the history of artificial intelligence."" } ] }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
#include <stdio.h>#include <curl/curl.h>int main(void) { CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { const char *url = "https://api.apimart.ai/v1/chat/completions"; // "gpt-5" はサポートされている任意のモデルIDに置き換え可能 const char *payload = "{" "\"model\":\"gpt-5\"," "\"messages\":[{\"role\":\"system\",\"content\":\"You are a professional AI assistant.\"},{\"role\":\"user\",\"content\":\"Tell me about the history of artificial intelligence.\"}]" "}"; struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Authorization: Bearer <token>"); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); if(res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); } curl_slist_free_all(headers); curl_easy_cleanup(curl); } curl_global_cleanup(); return 0;}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/chat/completions"(* サポートされている任意のモデルIDに置き換え可能 *)let payload = {|{ "model": "gpt-5", "messages": [ { "role": "system", "content": "You are a professional AI assistant." }, { "role": "user", "content": "Tell me about the history of artificial intelligence." } ]}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/chat/completions"# サポートされている任意のモデルIDに置き換え可能payload <- list( model = "gpt-5", messages = list( list( role = "system", content = "You are a professional AI assistant." ), list( role = "user", content = "Tell me about the history of artificial intelligence." ) ))response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))
import Foundationlet url = URL(string: "https://api.apimart.ai/v1/chat/completions")!let payload: [String: Any] = [ "model": "gpt-5", // サポートされている任意のモデルIDに置き換え可能 "messages": [ [ "role": "system", "content": "You are a professional AI assistant." ], [ "role": "user", "content": "Tell me about the history of artificial intelligence." ] ]]var request = URLRequest(url: url)request.httpMethod = "POST"request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")request.setValue("application/json", forHTTPHeaderField: "Content-Type")request.httpBody = try? JSONSerialization.data(withJSONObject: payload)let task = URLSession.shared.dataTask(with: request) { data, response, error in if let error = error { print("Error: \(error)") return } if let data = data, let responseString = String(data: data, encoding: .utf8) { print(responseString) }}task.resume()
using System;using System.Net.Http;using System.Text;using System.Threading.Tasks;class Program{ static async Task Main(string[] args) { var url = "https://api.apimart.ai/v1/chat/completions"; // サポートされている任意のモデルIDに置き換え可能 var payload = @"{ ""model"": ""gpt-5"", ""messages"": [ { ""role"": ""system"", ""content"": ""You are a professional AI assistant."" }, { ""role"": ""user"", ""content"": ""Tell me about the history of artificial intelligence."" } ] }"; using var client = new HttpClient(); client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>"); var content = new StringContent(payload, Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, content); var result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }}
#include <stdio.h>#include <curl/curl.h>int main(void) { CURL *curl; CURLcode res; curl_global_init(CURL_GLOBAL_DEFAULT); curl = curl_easy_init(); if(curl) { const char *url = "https://api.apimart.ai/v1/chat/completions"; // "gpt-5" はサポートされている任意のモデルIDに置き換え可能 const char *payload = "{" "\"model\":\"gpt-5\"," "\"messages\":[{\"role\":\"system\",\"content\":\"You are a professional AI assistant.\"},{\"role\":\"user\",\"content\":\"Tell me about the history of artificial intelligence.\"}]" "}"; struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "Authorization: Bearer <token>"); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); res = curl_easy_perform(curl); if(res != CURLE_OK) { fprintf(stderr, "curl_easy_perform() failed: %s\n", curl_easy_strerror(res)); } curl_slist_free_all(headers); curl_easy_cleanup(curl); } curl_global_cleanup(); return 0;}
(* Requires cohttp and yojson libraries *)open Lwtopen Cohttpopen Cohttp_lwt_unixlet url = "https://api.apimart.ai/v1/chat/completions"(* サポートされている任意のモデルIDに置き換え可能 *)let payload = {|{ "model": "gpt-5", "messages": [ { "role": "system", "content": "You are a professional AI assistant." }, { "role": "user", "content": "Tell me about the history of artificial intelligence." } ]}|}let () = let headers = Header.init () |> fun h -> Header.add h "Authorization" "Bearer <token>" |> fun h -> Header.add h "Content-Type" "application/json" in let body = Cohttp_lwt.Body.of_string payload in let response = Client.post ~headers ~body (Uri.of_string url) >>= fun (resp, body) -> body |> Cohttp_lwt.Body.to_string >|= fun body_str -> print_endline body_str in Lwt_main.run response
library(httr)library(jsonlite)url <- "https://api.apimart.ai/v1/chat/completions"# サポートされている任意のモデルIDに置き換え可能payload <- list( model = "gpt-5", messages = list( list( role = "system", content = "You are a professional AI assistant." ), list( role = "user", content = "Tell me about the history of artificial intelligence." ) ))response <- POST( url, add_headers( Authorization = "Bearer <token>", `Content-Type` = "application/json" ), body = toJSON(payload, auto_unbox = TRUE), encode = "raw")cat(content(response, "text"))