Chat Completions Client¶
The Chat Completions client provides methods for interacting with chat completion endpoints in the Opik platform.
- class opik.rest_api.chat_completions.client.ChatCompletionsClient(*, client_wrapper: SyncClientWrapper)¶
Bases:
object
- create_chat_completions(*, model: str | None = OMIT, messages: Sequence[Dict[str, Any | None]] | None = OMIT, temperature: float | None = OMIT, top_p: float | None = OMIT, n: int | None = OMIT, stream: bool | None = OMIT, stream_options: StreamOptions | None = OMIT, stop: Sequence[str] | None = OMIT, max_tokens: int | None = OMIT, max_completion_tokens: int | None = OMIT, presence_penalty: float | None = OMIT, frequency_penalty: float | None = OMIT, logit_bias: Dict[str, int] | None = OMIT, user: str | None = OMIT, response_format: ResponseFormat | None = OMIT, seed: int | None = OMIT, tools: Sequence[Tool] | None = OMIT, tool_choice: Dict[str, Any | None] | None = OMIT, parallel_tool_calls: bool | None = OMIT, store: bool | None = OMIT, metadata: Dict[str, str] | None = OMIT, reasoning_effort: str | None = OMIT, service_tier: str | None = OMIT, functions: Sequence[Function] | None = OMIT, function_call: FunctionCall | None = OMIT, request_options: RequestOptions | None = None) ChatCompletionResponse ¶
Create chat completions
- Parameters:
model (Optional[str])
messages (Optional[Sequence[Message]])
temperature (Optional[float])
top_p (Optional[float])
n (Optional[int])
stream (Optional[bool])
stream_options (Optional[StreamOptions])
stop (Optional[Sequence[str]])
max_tokens (Optional[int])
max_completion_tokens (Optional[int])
presence_penalty (Optional[float])
frequency_penalty (Optional[float])
logit_bias (Optional[Dict[str, int]])
user (Optional[str])
response_format (Optional[ResponseFormat])
seed (Optional[int])
tools (Optional[Sequence[Tool]])
tool_choice (Optional[Dict[str, Optional[Any]]])
parallel_tool_calls (Optional[bool])
store (Optional[bool])
metadata (Optional[Dict[str, str]])
reasoning_effort (Optional[str])
service_tier (Optional[str])
functions (Optional[Sequence[Function]])
function_call (Optional[FunctionCall])
request_options (Optional[RequestOptions]) – Request-specific configuration.
- Returns:
Chat completions response
- Return type:
Examples
from Opik import OpikApi client = OpikApi(api_key=”YOUR_API_KEY”, workspace_name=”YOUR_WORKSPACE_NAME”, ) client.chat_completions.create_chat_completions()
Usage Example¶
import opik
client = opik.Opik()
# Create a chat completion
response = client.rest_client.chat_completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Hello, how are you?"}
],
temperature=0.7
)