dev.ai4j.openai4j.OpenAiApi Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openai4j Show documentation
Show all versions of openai4j Show documentation
Java Client for OpenAI (ChatGPT)
package dev.ai4j.openai4j;
import dev.ai4j.openai4j.chat.ChatCompletionRequest;
import dev.ai4j.openai4j.chat.ChatCompletionResponse;
import dev.ai4j.openai4j.completion.CompletionRequest;
import dev.ai4j.openai4j.completion.CompletionResponse;
import dev.ai4j.openai4j.embedding.EmbeddingRequest;
import dev.ai4j.openai4j.embedding.EmbeddingResponse;
import dev.ai4j.openai4j.image.GenerateImagesRequest;
import dev.ai4j.openai4j.image.GenerateImagesResponse;
import dev.ai4j.openai4j.moderation.ModerationRequest;
import dev.ai4j.openai4j.moderation.ModerationResponse;
import java.util.Map;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.HeaderMap;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Query;
interface OpenAiApi {
@POST("completions")
@Headers("Content-Type: application/json")
Call completions(@Body CompletionRequest request,
@Query("api-version") String apiVersion);
@POST("completions")
@Headers("Content-Type: application/json")
Call completions(
@HeaderMap Map headers,
@Body CompletionRequest request,
@Query("api-version") String apiVersion);
@POST("chat/completions")
@Headers("Content-Type: application/json")
Call chatCompletions(
@Body ChatCompletionRequest request,
@Query("api-version") String apiVersion
);
@POST("chat/completions")
@Headers("Content-Type: application/json")
Call chatCompletions(
@HeaderMap Map headers,
@Body ChatCompletionRequest request,
@Query("api-version") String apiVersion
);
@POST("embeddings")
@Headers("Content-Type: application/json")
Call embeddings(
@Body EmbeddingRequest request,
@Query("api-version") String apiVersion);
@POST("embeddings")
@Headers("Content-Type: application/json")
Call embeddings(
@HeaderMap Map headers,
@Body EmbeddingRequest request,
@Query("api-version") String apiVersion);
@POST("moderations")
@Headers("Content-Type: application/json")
Call moderations(
@Body ModerationRequest request,
@Query("api-version") String apiVersion);
@POST("moderations")
@Headers("Content-Type: application/json")
Call moderations(
@HeaderMap Map headers,
@Body ModerationRequest request,
@Query("api-version") String apiVersion);
@POST("images/generations")
@Headers({"Content-Type: application/json"})
Call imagesGenerations(
@Body GenerateImagesRequest request,
@Query("api-version") String apiVersion
);
@POST("images/generations")
@Headers({"Content-Type: application/json"})
Call imagesGenerations(
@HeaderMap Map headers,
@Body GenerateImagesRequest request,
@Query("api-version") String apiVersion
);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy