OpenResponsesClient class
Dart client for the OpenResponses API.
Provides type-safe access to LLM models via the OpenResponses specification. Compatible with OpenAI, Ollama, Hugging Face, and other providers.
Basic Usage
final client = OpenResponsesClient(
config: OpenResponsesConfig(
authProvider: BearerTokenProvider('your-api-key'),
),
);
final response = await client.responses.create(
CreateResponseRequest(
model: 'gpt-4o',
input: ResponseTextInput('Hello, world!'),
),
);
print(response.outputText);
client.close();
Using with Ollama (Local)
final client = OpenResponsesClient(
config: OpenResponsesConfig(
baseUrl: 'http://localhost:11434/v1',
// No auth needed for local Ollama
),
);
Environment Configuration
final client = OpenResponsesClient.fromEnvironment();
// Uses OPENAI_API_KEY environment variable
Constructors
- OpenResponsesClient({OpenResponsesConfig? config, Client? httpClient})
- Creates an OpenResponsesClient.
- OpenResponsesClient.fromEnvironment({Client? httpClient})
-
Creates an OpenResponsesClient from environment variables.
factory
-
OpenResponsesClient.withApiKey(String apiKey, {String? baseUrl, Map<
String, String> ? defaultHeaders, Client? httpClient}) -
Creates an OpenResponsesClient with the given API key.
factory
Properties
- config → OpenResponsesConfig
-
Client configuration.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- httpClient → Client
-
Gets the HTTP client for streaming requests.
no setter
- interceptorChain → InterceptorChain
-
Gets the interceptor chain for advanced usage.
no setter
- requestBuilder → RequestBuilder
-
Gets the request builder for advanced usage.
no setter
- responses ↔ ResponsesResource
-
Resource for the Responses API.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
) → void - Closes the client and releases resources.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited