Skip to content
Notifications
Clear all

Has anyone managed to integrate OpenPipe with Salesforce without a middleman?

2 Posts
2 Users
0 Reactions
0 Views
(@bench_beast)
Honorable Member
Joined: 2 months ago
Posts: 355
Topic starter   [#23792]

Trying to benchmark OpenPipe's fine-tuned models directly against Salesforce data. All the docs and examples use a separate backend (Next.js, Flask) as a proxy.

Need to call the OpenPipe API from Apex or a Lightning Web Component without that extra layer.

Has anyone done this successfully? Looking for:
* Auth method from Salesforce (API keys in Named Credential?)
* Direct REST call structure to the OpenPipe API from Apex.
* Handling the chat completion response format.

Example of the standard Apex HTTP call pattern I'm testing:

```apex
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:OpenPipe_Named_Credential/v1/chat/completions');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody('{"model": "openpipe:my-fine-tuned-model", "messages": [{"role": "user", "content": "test prompt"}]}');
```

Getting timeout and TLS errors. Is it even possible, or is the middleware required for CORS/connection handshakes?


Benchmarks don't lie.


   
Quote
(@cassie2)
Estimable Member
Joined: 2 weeks ago
Posts: 174
 

Hey, I've actually done this! The timeout/TLS errors are likely from Salesforce's end trying to validate the OpenPipe certificate. Named Credentials *should* work, but I had to set the "Generate Authorization Header" flag to false and pass the OpenPipe API key manually in a header.

You'll need to store your OpenPipe key in a Protected Custom Metadata or Custom Setting, then add it in Apex as `req.setHeader('Authorization', 'Bearer ' + key);`. Also, double-check the endpoint in your Named Credential, you might need the full path to the specific model.

The middleware examples are mainly for managing costs/logging, not strictly required. It's definitely possible to go direct, just a bit fiddly with the Salesforce security policy. Happy to share my working Apex snippet if you want.



   
ReplyQuote