public class OpenCodeChatClient extends OpenCodeHttpClient
普通 Prompt/Chat 调用继承自 OpenCodeHttpClient;事件订阅是流式聊天的
内部实现细节,业务调用方通过本类即可完成两种响应模式。
| Constructor and Description |
|---|
OpenCodeChatClient(OpenCodeHttpClientConfig config)
创建 open code chat client 实例,并按传入依赖确定资源所有权。
|
OpenCodeChatClient(OpenCodeHttpClientConfig config,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
okhttp3.OkHttpClient httpClient)
创建 open code chat client 实例,并按传入依赖确定资源所有权。
|
OpenCodeChatClient(OpenCodeHttpClientConfig config,
com.fasterxml.jackson.databind.ObjectMapper objectMapper,
okhttp3.OkHttpClient httpClient,
OpenCodeSseClient sseClient)
创建 open code chat client 实例,并按传入依赖确定资源所有权。
|
abortSession, addMcpServer, awaitFuture, chatCompletionWithSession, chatCompletionWithSession, chatCompletionWithSessionAsync, createSession, createSession, createSession, createSessionAsync, deleteSession, disposeInstance, ensureSession, ensureSession, ensureSession, ensureSessionAsync, executeAsync, find, findFiles, findSessionByTitle, findSessionByTitle, findSessionByTitle, findSymbols, forkSession, getConfig, getConfigProviders, getCurrentProject, getFileContent, getFileStatus, getGlobalConfig, getMessage, getMessages, getObjectMapper, getOkHttpClient, getPath, getSession, getSessionChildren, getSessionDiff, getSessionStatusMap, getSessionTodo, getVcs, globalDispose, globalUpgrade, health, healthAsync, initProjectGit, initSession, listAgents, listCommands, listFiles, listFormatters, listLsps, listMcpServers, listPermissions, listProjects, listProviderAuthMethods, listProviders, listQuestions, listSessions, listSessions, listSessions, listSessionsAsync, listSkills, prompt, prompt, promptAsync, promptAsync, promptCompletionAsync, providerOAuthAuthorize, providerOAuthCallback, providerOAuthCallbackAsync, rejectQuestion, removeAuth, replyPermission, replyQuestion, revertSession, runSessionCommand, setAuth, setAuthAsync, shareSession, summarizeSession, unrevertSession, unshareSession, updateConfig, updateGlobalConfig, updateProjectpublic OpenCodeChatClient(OpenCodeHttpClientConfig config)
config - 客户端配置;不得为 nullpublic OpenCodeChatClient(OpenCodeHttpClientConfig config, com.fasterxml.jackson.databind.ObjectMapper objectMapper, okhttp3.OkHttpClient httpClient)
config - 客户端配置;不得为 nullobjectMapper - JSON 映射器;为 null 时使用 SDK 默认配置httpClient - 可复用的 OkHttp 客户端;为 null 时由 SDK 创建public OpenCodeChatClient(OpenCodeHttpClientConfig config, com.fasterxml.jackson.databind.ObjectMapper objectMapper, okhttp3.OkHttpClient httpClient, OpenCodeSseClient sseClient)
config - 客户端配置;不得为 nullobjectMapper - JSON 映射器;为 null 时使用 SDK 默认配置httpClient - 可复用的 OkHttp 客户端;为 null 时由 SDK 创建sseClient - SSE 客户端;为 null 时按配置创建public ChatResponse chatCompletion(String sessionId, ChatRequest request)
sessionId - OpenCode 会话 ID;不得为空request - 请求对象;不得为 nullOpenCodeHttpException - HTTP 请求失败或响应无法解析public CompletableFuture<ChatResponse> chatCompletionAsync(String sessionId, ChatRequest request)
sessionId - OpenCode 会话 ID;不得为空request - 请求对象;不得为 nullpublic ChatResponse chatCompletionWithSession(ChatRequest request, String sessionKey)
request - 请求对象;不得为 nullsessionKey - 用于稳定复用会话的业务键;相同键映射到同一标题OpenCodeHttpException - HTTP 请求失败或响应无法解析public ChatResponse chatCompletionWithSession(ChatRequest request, String sessionKey, HttpCallCancellation cancellation)
request - 请求对象;不得为 nullsessionKey - 用于稳定复用会话的业务键;相同键映射到同一标题cancellation - 取消信号;为 null 时不可由外部取消OpenCodeHttpException - HTTP 请求失败或响应无法解析public CompletableFuture<ChatResponse> chatCompletionWithSessionAsync(ChatRequest request, String sessionKey, HttpCallCancellation cancellation)
request - 请求对象;不得为 nullsessionKey - 用于稳定复用会话的业务键;相同键映射到同一标题cancellation - 取消信号;为 null 时不可由外部取消public StreamingChatResponse chatCompletionStream(ChatRequest request, String sessionKey)
request - 请求对象;不得为 nullsessionKey - 用于稳定复用会话的业务键;相同键映射到同一标题public StreamingChatResponse chatCompletionStream(ChatRequest request, String sessionKey, OpenCodeRequestContext context)
request - 请求对象;不得为 nullsessionKey - 用于稳定复用会话的业务键;相同键映射到同一标题context - 请求上下文;为 null 时不附加目录头public StreamingChatResponse chatCompletionStream(ChatRequest request, String sessionKey, OpenCodeRequestContext context, Consumer<String> deltaConsumer)
request - 请求对象;不得为 nullsessionKey - 用于稳定复用会话的业务键;相同键映射到同一标题context - 请求上下文;为 null 时不附加目录头deltaConsumer - 文本增量消费者;不得为 nullpublic void close()
close in interface AutoCloseableclose in class OpenCodeHttpClientCopyright © 2026. All rights reserved.