|
| 1 | +# guardrails_api_client.OpenaiApi |
| 2 | + |
| 3 | +All URIs are relative to *http://localhost* |
| 4 | + |
| 5 | +Method | HTTP request | Description |
| 6 | +------------- | ------------- | ------------- |
| 7 | +[**openai_chat_completion**](OpenaiApi.md#openai_chat_completion) | **POST** /guards/{guardName}/openai/v1/chat/completions | OpenAI SDK compatible endpoint for Chat Completions |
| 8 | + |
| 9 | + |
| 10 | +# **openai_chat_completion** |
| 11 | +> OpenAIChatCompletion openai_chat_completion(guard_name, open_ai_chat_completion_payload) |
| 12 | +
|
| 13 | +OpenAI SDK compatible endpoint for Chat Completions |
| 14 | + |
| 15 | +### Example |
| 16 | + |
| 17 | +* Api Key Authentication (ApiKeyAuth): |
| 18 | +* Bearer (JWT) Authentication (BearerAuth): |
| 19 | + |
| 20 | +```python |
| 21 | +import guardrails_api_client |
| 22 | +from guardrails_api_client.models.open_ai_chat_completion import OpenAIChatCompletion |
| 23 | +from guardrails_api_client.models.open_ai_chat_completion_payload import OpenAIChatCompletionPayload |
| 24 | +from guardrails_api_client.rest import ApiException |
| 25 | +from pprint import pprint |
| 26 | + |
| 27 | +# Defining the host is optional and defaults to http://localhost |
| 28 | +# See configuration.py for a list of all supported configuration parameters. |
| 29 | +configuration = guardrails_api_client.Configuration( |
| 30 | + host = "http://localhost" |
| 31 | +) |
| 32 | + |
| 33 | +# The client must configure the authentication and authorization parameters |
| 34 | +# in accordance with the API server security policy. |
| 35 | +# Examples for each auth method are provided below, use the example that |
| 36 | +# satisfies your auth use case. |
| 37 | + |
| 38 | +# Configure API key authorization: ApiKeyAuth |
| 39 | +configuration.api_key['ApiKeyAuth'] = os.environ["API_KEY"] |
| 40 | + |
| 41 | +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed |
| 42 | +# configuration.api_key_prefix['ApiKeyAuth'] = 'Bearer' |
| 43 | + |
| 44 | +# Configure Bearer authorization (JWT): BearerAuth |
| 45 | +configuration = guardrails_api_client.Configuration( |
| 46 | + access_token = os.environ["BEARER_TOKEN"] |
| 47 | +) |
| 48 | + |
| 49 | +# Enter a context with an instance of the API client |
| 50 | +with guardrails_api_client.ApiClient(configuration) as api_client: |
| 51 | + # Create an instance of the API class |
| 52 | + api_instance = guardrails_api_client.OpenaiApi(api_client) |
| 53 | + guard_name = 'guard_name_example' # str | Guard name |
| 54 | + open_ai_chat_completion_payload = guardrails_api_client.OpenAIChatCompletionPayload() # OpenAIChatCompletionPayload | |
| 55 | + |
| 56 | + try: |
| 57 | + # OpenAI SDK compatible endpoint for Chat Completions |
| 58 | + api_response = api_instance.openai_chat_completion(guard_name, open_ai_chat_completion_payload) |
| 59 | + print("The response of OpenaiApi->openai_chat_completion:\n") |
| 60 | + pprint(api_response) |
| 61 | + except Exception as e: |
| 62 | + print("Exception when calling OpenaiApi->openai_chat_completion: %s\n" % e) |
| 63 | +``` |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +### Parameters |
| 68 | + |
| 69 | + |
| 70 | +Name | Type | Description | Notes |
| 71 | +------------- | ------------- | ------------- | ------------- |
| 72 | + **guard_name** | **str**| Guard name | |
| 73 | + **open_ai_chat_completion_payload** | [**OpenAIChatCompletionPayload**](OpenAIChatCompletionPayload.md)| | |
| 74 | + |
| 75 | +### Return type |
| 76 | + |
| 77 | +[**OpenAIChatCompletion**](OpenAIChatCompletion.md) |
| 78 | + |
| 79 | +### Authorization |
| 80 | + |
| 81 | +[ApiKeyAuth](../README.md#ApiKeyAuth), [BearerAuth](../README.md#BearerAuth) |
| 82 | + |
| 83 | +### HTTP request headers |
| 84 | + |
| 85 | + - **Content-Type**: application/json |
| 86 | + - **Accept**: application/json |
| 87 | + |
| 88 | +### HTTP response details |
| 89 | + |
| 90 | +| Status code | Description | Response headers | |
| 91 | +|-------------|-------------|------------------| |
| 92 | +**200** | The output of the completion | - | |
| 93 | +**0** | Unexpected error | - | |
| 94 | + |
| 95 | +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) |
| 96 | + |
0 commit comments